+ 6

What is the ouput of "10" + 20 + 30 in JAVASCRIPT

Try to test your brain 💰💰💰

10th Feb 2018, 8:11 AM
Oston Code Cypher
Oston Code Cypher - avatar
11 Antworten
+ 4
Think it is "102030"
10th Feb 2018, 8:13 AM
Leonardo Medai Cossutta
Leonardo Medai Cossutta - avatar
+ 18
Math...... >.< My brain just crashed !!!
10th Feb 2018, 8:12 AM
Frost
Frost - avatar
+ 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".
12th Feb 2018, 2:16 AM
UnknownYmous
+ 3
@MrCoder, the answer is the string "102030" because JavaScript evaluates it from left to right. "10" + 20 + 30 "1020" + 30 "102030"
10th Feb 2018, 1:16 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 2
how??? please explain this...
10th Feb 2018, 8:57 AM
shakil sharif
shakil sharif - avatar
+ 1
var num = "10" + 20 + 30; document.write(num); the answer is "102030" because "10" is a string.
11th Feb 2018, 5:02 AM
shahid
shahid - avatar
0
Because the first number is a string
10th Feb 2018, 8:59 AM
Leonardo Medai Cossutta
Leonardo Medai Cossutta - avatar
0
Its 1050 isn't it? 20+30 = 50 "10"+50 (50 = convert to string) 1050
10th Feb 2018, 1:00 PM
MrCoder
MrCoder - avatar
- 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.
17th Feb 2018, 6:50 AM
Shivam Bablikar
Shivam Bablikar - avatar
- 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".
17th Feb 2018, 6:50 AM
Shivam Bablikar
Shivam Bablikar - avatar
- 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.
13th Feb 2018, 3:43 AM
Bhavya Sree K
Bhavya Sree K - avatar