Tell us what’s happening:
Hey Fellow Campers -
I’m trying to get through this one without looking at the hint lol. I’ve got 3 of the tests passed. But currying the function I’m finding difficult. Now I can pass the curry test making a curried function, but then the other tests fail.
I’m not sure how to combine a curried function with non-curried function. If I do this as a curried function, I have no idea how to modify it to work with the rest of the functions.
function add(x) {
// Add your code below this line
return function(y) {
return x + y;
}
// Add your code above this line
}
This is my code so far without the curried part. Thanks and code on!
Your code so far
function addTogether() {
var args = Array.prototype.slice.call(arguments); // creates an array with arguments
console.log(args);
for (let i = 0; i < args.length; ++i) {
console.log(args[i]);
if (typeof args[i] !== 'number') {
return undefined;
}
}
return args.reduce(function (previousValue, currentValue) { // adds and returns the sum
return previousValue + currentValue;
});
}
addTogether(2,3);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional/