+ 2
Why does the JS code not work?
Inserted JS code doesn't work but it there is in JS Challenge. Do I not understand something? : ) https://code.sololearn.com/WUKxGJJDTnOs/?ref=app
59 Answers
+ 7
Default parameter value doesn't work in old browsers. You may try this...
function x (a, b, c) {
a=a||1;
b=b||5;
c=c||6;
return a+b-c;
}
document.write(x(7,4));
//output 5
+ 21
Function x have default parameters.
When you call it x(7,4) means a=7 b=4 c=6 and 7+4-6=5
For more information:
https://developer.mozilla.org/th/docs/Web/JavaScript/Reference/Functions/Default_parameters
0
works fine 7+4-6=5, a=7, b=4, and c uses default of 6.