JavaScript question ???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

JavaScript question ????

var a = "4"; var b = parseInt(a,10); var c = "8"; var d = parseInt(c,10); var e = document.write(b+d); I understande 4 + 8 = 12 but what happened with the 10 number ?

12th Mar 2017, 8:10 PM
Martin Daigneault
Martin Daigneault - avatar
2 Answers
+ 2
The second argument from the parseInt function, known as radix, tells to which numeral system the string should be converted to. in this case 10 would be the decimal system, so just a normal number. but if the string was for example "04" it would return 4 as well.
12th Mar 2017, 8:25 PM
Petar Dimitrov
Petar Dimitrov - avatar
+ 1
the 10 is the numerical base(radix)! in this case, is decimal cause it's 10.
12th Mar 2017, 8:30 PM
Welliton Malta
Welliton Malta - avatar