Challenge Arguments Optional has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
function addTogether(num1, num2) {
if (arguments.length<2){
if((typeof(num1)!=="number")){
return undefined;
}
return function addmore(num2){
if((typeof(num1)!=="number")||(typeof(num2)!=="number")){
return undefined;
}
return num1+num2;
};
}
if((typeof(num1)!=="number")||(typeof(num2)!=="number")){
return undefined;
}
return num1+num2;
}
addTogether(2);
Well, the title pretty much explains it. When I execute the code it passes the objectives on green but the "you win" pop-up wont appear and the black box stays on "testing challenge..." Checking the console I got an error that reads "Uncaught TypeError: Cannot read property 'split' of undefined"..
Any advise?
@Quartzito The problem is with your custom test case: addTogether(2);. All the actual test cases work fine.
I can confirm this error despite the fact that the code is a valid solution. Seems that calling a function that returns a function on the final line of a solution breaks our code execution? Whatever the case you shouldn't be able to completely crash the JS environment for FCC with valid code (which this code does).
Most helpful comment
@Quartzito The problem is with your custom test case:
addTogether(2);. All the actual test cases work fine.