Tell us what’s happening:
The given answers are understandable. I tried to pass ‘first’ as an argument also into construction of the function that is to be returned. This is however not working. Unable to understand why this is not working. Thanks in advance for any explanation
Your code so far
function addTogether(...args) {
const [first, second] = args;
if (args.length === 1 && typeof first === 'number') {
let tempFunction = (num,first) => {
if (typeof num === 'number') {
return first + num;
}else{
return undefined;
}
};
return tempFunction;
}
if (typeof first === 'number' && typeof second === 'number') {
return first + second;
}
}
console.log(addTogether(5)(7));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Arguments Optional
Link to the challenge: