Tell us what’s happening:
Well, my code is messy and all
Is there a shorter way to write this while keeping it readable?
I tried freecodecamp advanced solution but honestly, it even more messy as it is not readable nor maintainable.
Your code so far
js
function addTogether() {
if (typeof arguments[0] === "number" || typeof arguments[1] === "number") {
var original = arguments[0];
if (arguments.length === 1) {
return function waiting(value) {
return original + value;
}
}
if (typeof arguments[0] === "number" && typeof arguments[1] === "number") {
return arguments[0] + arguments[1];
}
}
return undefined;
}
addTogether(2,3);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0.
Don’t feel bad. Usually you’ll have to see a different way to do something to know that it’s even possible. I saw this trick in someone else’s code, and now you know it too