Tell us what’s happening:
At the last step:
console.log(args[0] + args[1]); // 5
return args[0] + args[1]; // undefined
I can’t find the bug…
Your code so far
"use strict";
function addTogether() {
let args = [...arguments];
if (!(args.every((val) => (typeof val) == "number"))) {
return undefined;
}
if (args.length < 2) {
return function(secondNumber) {
addTogether(secondNumber, args[0]);
}
}
console.log(args[0] + args[1]);
return args[0] + args[1];
}
console.log(addTogether(2)(3));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 OPR/60.0.3255.95
.
Link to the challenge: