Tell us what’s happening:
In the challenge linked below, it is asked “If either argument isn’t a valid number, return undefined.”
Please, consider adding a test where the first argument isn’t a valid number, but the second is.
I passed the challenge with this code:
//buggy function
function addTogether(...args) {
if (arguments.length == 1 && typeof(args[0]) == 'number')
return ( val => (typeof(val) === 'number') ? args[0] + val : undefined );
if (arguments.length >= 2 && typeof(args[1]) == 'number'){
return args[0] + args[1];
} else
return undefined;
}
//test code
addTogether("2", 3); // gives 23, not 5 as expected
Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.