Skip to content

Instantly share code, notes, and snippets.

@epzee
epzee / flatten.js
Last active November 14, 2017 15:33
citrusbyte - flatten // tested on https://repl.it/languages/jest
const reducer = (result, item) => {
const flattened = Array.isArray(item) ? flatten(item) : item;
return result.concat(flattened);
}
const flatten = (array) => array.reduce(reducer, []);
module.exports = flatten;
// Add your javascript here
const endpoint = 'https://jsonmock.hackerrank.com/api/movies/search/';
const input = document.getElementById('q');
const form = document.getElementById('search_form');
const list = document.getElementById('results');
form.addEventListener('submit', async (e) => {
e.preventDefault();
function maxDifference(a) {
let maxDiff = -1;
let min = a[0];
for (let i = 1; i < a.length; i++) {
if (a[i] - min > maxDiff) {
// update diff if greater diff was found
maxDiff = a[i] - min;
}
function doubleSize(a, b) {
let max = b;
a.sort().forEach(item => {
if (item === max) {
max = max * 2;
}
})
return max;
$one->up();
$one->down();
$one->right();
$one->left();