Do you know what will be the output of this code?
JavaScript
function add(a, b) {
return a + b;
}
console.log(add(1));
Show answer and explanation
The answer is NaN.
JavaScript doesn’t check the number of arguments. b is undefined, and 1 + undefined is NaN. A default like b = 0 avoids this.