Hello. I am working on Arguments Optional in the intermediate scripting section. https://www.freecodecamp.org/challenges/arguments-optional
I am receiving the error message: “TypeError: Num is not a Function”. It is saying that variables first and second are used out of scope. Could I get some help with this?
function addTogether() {
//turn object into array
var nums = [].slice.call(arguments);
//call a function on every item in array
if (!nums.every(function(num){
//if the array contains only numbers, return numbers
//Otherwise, return undefined
return typeof(num) =='number' ? num : undefined;
}))
//assign first and second nums in array to variables
var first = nums(arguments[0]);
var second = nums(arguments[1]);
if (arguments.length==2) {
return first + second;
} else {
return undefined;
}
if (first) {
return function(third) {
return first + third;
};
} else {
return undefined;
}
return false;
}
addTogether(2,3);