The console shows the right number, the sum is exactly 5, but the test shows that it is not right( X ). Anyone can help
Your code so far
function add(num) {
sum += num;
return sum;
}
function checkNum(num) {
if (typeof num === "number") {
return num;
} else {
return undefined;
}
}
if (arguments.length > 1) {
for (var a in arguments) {
if (checkNum(arguments[a])) {
add(arguments[a]);
} else {
return undefined;
}
}
} else {
if (checkNum(arguments[0])) {
add(arguments[0]);
counter++;
if (counter < 2) {
return addTogether;
} else {
//console.log(sum);
}
} else {
return undefined;
}
}
return sum;
}
var sum = 0;
var counter = 0;
addTogether(2, 3);```
**Your browser information:**
Your Browser User Agent is: ```Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36```.
**Link to the challenge:**
https://www.freecodecamp.org/challenges/arguments-optional