A little confused on this code why it is not working for the last two cases. As far as I understand it JavaScript doesn’t have tight ‘type casting’ like other langs, so why does ‘NaN’ not work here ?
- A
Your code so far
function addTogether(a, b) {
if (isNaN(a)) {
return undefined;
}
if (b != null) {
return a + b;
}
return function Sum(x) {
if (isNaN(x)) {
return undefined;
} else {
return a + x;
}
};
}
addTogether(2,3);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
.
Link to the challenge: