0

Why does this code output 4?

function f(x) { if (x==4) return 4; else return(x+1); }; alert (f(1));

18th Mar 2018, 8:06 PM
Briaה‎
4 Answers
+ 8
The output is 2 not 4.. You can write this in SL code playground.. you will see that the output is 2 Check it: https://code.sololearn.com/WVyh1Q7otevj/?ref=app
18th Mar 2018, 8:10 PM
Baraa AB
Baraa AB - avatar
+ 3
@Brain no problem.. and good luck bro <3
18th Mar 2018, 8:33 PM
Baraa AB
Baraa AB - avatar
+ 1
Why would the output not be 2?
18th Mar 2018, 8:18 PM
Tomer Sim
Tomer Sim - avatar
+ 1
Thanks Baraa! Had to be sure it wasn't just me.
18th Mar 2018, 8:30 PM
Briaה‎