+ 2
Why is x = 7?
function myFunction(a, b) { a++; b++; return (a ,b); } var x = myFunction(5, 6); document.write(x);
11 Respuestas
+ 1
+ 1
return (a,b);
/ return statement will not return two values here
it will return only b
0
why
0
return statements sends back only one result to validate it
0
Thank You so much! Can u explain to me this. Why doesn't the function stop at return as return is supposed to stop the execution of a function. So shouldn't the answer be 3 rather then 5
function test(x)
{while (x<5){x++;}return x;}
alert(test(2));
0
the last value is 5 because x is incremented to 1 and returns 5
0
when 2 gets incremented to 3, why doesn't the function stop and return the final value as 3?
0
its while loop , it will not end until the statement becomes false
0
if you want to return when x=3 , put if else statement
0
a = 6
b = 7
returns the highest number between these 2 numbers
0
Hi Raul Oliva. Just to correct your statement,
function myFunction(a, b, c) {
a++;
b++;
c++;
return (a,b,c);
}
var x = myFunction(5, 9, 7);
document.write(x); //Outputs : 8
Although highest value is 10, it only returns the last calculated value, which is 8