0

Why is it 1.

function test(a,b=0, c =2) { return a/b/c } console.log(test(2,1));

21st Sep 2019, 10:16 AM
Oladayo Ahmod
Oladayo Ahmod - avatar
1 Odpowiedź
+ 3
you are passing two values to test() so they are assigned to first two parameters a, b, and c remains with default value (2). now a=2, b=1 and c=2 evaluating a/b/c = 2/1/2 from left to right we get 2/1 =2 and then 2/2=1
21st Sep 2019, 11:16 AM
Nidhi