node-quiz
node-quiz copied to clipboard
Fail in the first question
Currently,
var result = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) {
return a.concat(b.reverse());
});
console.log(result);
And the right answer for that is:
[ 0, 1, 3, 2, 5, 4 ]
Because you did not defined the initial value.
The right answer as the question asked would be: [ 1, 0, 3, 2, 5, 4 ]
To reach this you need to initialize the "memo" as an empty array:
var result = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) {
return a.concat(b.reverse());
}, []);
console.log(result);
Fix the question or the answer please :)
Could you send a PR please?
Yes if you tell me what do you want. Fix the answer of fix the question.
Your call