+ 6
What is the ouput of "10" + 20 + 30 in JAVASCRIPT
Try to test your brain 💰💰💰
11 Réponses
+ 4
Think it is "102030"
+ 18
Math...... >.<
My brain just crashed !!!
+ 11
First of all Javascript compile the programs from left to right.
Therefore, "10" is a String and it is in left side.
when it is add with 20. It convert "20" to a String.
"10" + "20" + 30 => "1020" + 30.
and at last it is add with 30. It convert "30" to a String.
"10" + "20" + "30" => "102030".
+ 3
@MrCoder, the answer is the string "102030" because JavaScript evaluates it from left to right.
"10" + 20 + 30
"1020" + 30
"102030"
+ 2
how??? please explain this...
+ 1
var num = "10" + 20 + 30;
document.write(num);
the answer is "102030" because "10" is a string.
0
Because the first number is a string
0
Its 1050 isn't it?
20+30 = 50
"10"+50 (50 = convert to string)
1050
- 1
var x="10", y= 20+30;
document.write(x+y);
Result: 1050!!
as the X value remains as a string and the Y value sums up the numbers. Upon adding the variables, it results as a String Concatenation.
- 2
First of all Javascript compile the programs from left to right.
Therefore, "10" is a String and it is in left side.
when it is add with 20. It convert "20" to a String.
"10" + "20" + 30 => "1020" + 30.
and at last it is add with 30. It convert "30" to a String.
"10" + "20" + "30" => "102030".
- 3
var x="10", y= 20+30;
document.write(x+y);
Result: 1050!!
as the X value remains as a string and the Y value sums up the numbers. Upon adding the variables, it results as a String Concatenation.