Tell us what’s happening:
Not sure what to do to pass the last test. The second arg is a number inside an array. It should return undefined like the other tests but instead it get concatenated with the first argument.
Your code so far
function addTogether() {
// converts args obj into an array
const args = Array.prototype.slice.call(arguments)
for (let i = 0; i < args.length; i++) {
if (typeof args[i] !== 'number') {
return undefined
}
else if (args.length === 1 && typeof args[i] === 'number') {
return function(c) {
return args[i] + c
}
}
}
return args.reduce((p, c) => p + c, 0)
}
console.log(addTogether(2)([3]))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional