How to add two numbers on web page using javascript? | javascript lecture 6 | how to do this

Опубликовано: 04 Октябрь 2024
на канале: arbn Studios
1,577
27

Adding two fields of html in javascript. This is lecture is totally based on adding two fields of html that user will give using javascript. Many students asks many questions.
I am adding two numbers, but I don't get a correct value.
For example, doing 1 + 2 returns 12 and not 3.
What am I doing wrong in this code?

The answer is:-
You need to use javaScript's parseInt() method to turn the strings back into numbers. Right now they are strings so adding two strings concatenates them, which is why you're getting "12"..

please subscribe us for your support🙏.How To Do This

Watch carefully . If you have any question then comment below or

join us on Facebook:-

  / 1184520091737540  

Send task at:-
[email protected]

Good luck