+ 2

What is wrong here? (JAVASCRIPT)

function num(a,b){ document.write(a+"is greater than"+b); } var x=num(18,16); alert(x);

15th Jan 2017, 11:32 AM
Simone Gramegna
Simone Gramegna - avatar
2 Answers
+ 4
You are wrong. Nah jk, it should be, function num(a,b){ alert(a+"is greater than"+b); } num(18,16); OR function num(a,b){ return a+"is greater than"+b } var x=num(18,16); alert(x);
15th Jan 2017, 11:34 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
0
function num(a,b) { if(a > b) return document.write(a+"is greater than"+b); else return document.write(b+"is greater than"+a); } var x = num(18, 16); alert(x); works for any number .. greater or less than.
15th Jan 2017, 11:42 AM
Franky BrainBox
Franky BrainBox - avatar