Tell us what’s happening:
Describe your issue in detail here:
When I console.log(arguments), I get two object:
1.{ ‘0’: 5 }
2.{ ‘0’: 7, ‘1’: 7 }
I do not know why the arguments[0] has changed from 5 to 7 in addTogether() function. Can you explain that to me? And how to solve this problem? Thank you so much.
return function addNumTwo(num2){
return addTogether(arguments[0], num2)
}
At this point where you return the addNumTwo, your arguments object no longer points to the outermost addTogether function but instead points to the arguments of the addNumTwo function.
function addTogether() {
const addTogetherArgs = arguments
if(arguments.length === 1){
return function addNumTwo(num2){
return addTogether(addTogetherArgs[0], num2)
}
You could store the first argument objects first and then access it inside of the addNumTwo function. This way your original arguments object is preserved.