This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doubleSize(a, b) { | |
let max = b; | |
a.sort().forEach(item => { | |
if (item === max) { | |
max = max * 2; | |
} | |
}) | |
return max; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$one->up(); | |
$one->down(); | |
$one->right(); | |
$one->left(); |