How we add two int in javascript without getting catenation .make sure number taken by user | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How we add two int in javascript without getting catenation .make sure number taken by user

14th Jul 2020, 12:44 AM
Raghvendra Singh chandel
Raghvendra Singh chandel - avatar
7 Answers
+ 2
When I try the code I provided earlier, it works perfectly for me. E.g. Input: 8 Input: 13 Output: 21 Remember that you can’t enter words like eight or five into the input boxes. Please tell us what you input and what you get as an output.
14th Jul 2020, 5:43 AM
Rowsej
Rowsej - avatar
+ 2
You can look this tutorial and I hope you will get your answer.. https://code.sololearn.com/c4I400c9D4As/?ref=app
25th Aug 2020, 7:28 PM
Durgesh Nigam
Durgesh Nigam - avatar
+ 1
It's not work I triead that method but still number concatinate but I want addition
14th Jul 2020, 1:21 AM
Raghvendra Singh chandel
Raghvendra Singh chandel - avatar
+ 1
Okk I get it .Earlier I doesn't include number so it take as a string .One more thing plz tell Number take as a variable or Number is a predefine
14th Jul 2020, 7:00 AM
Raghvendra Singh chandel
Raghvendra Singh chandel - avatar
+ 1
The Number function is a predefined function that converts something to a number (either an integer or a float/double).
14th Jul 2020, 7:11 AM
Rowsej
Rowsej - avatar
0
var variable1 = Number(prompt("Enter a number:")); var variable2 = Number(prompt("Enter another number:")); document.write(variable1 + variable2); // The Number function turns a variable into a number.
14th Jul 2020, 1:17 AM
Rowsej
Rowsej - avatar
0
Durgesh Nigam JavaScript, not Java.
25th Aug 2020, 10:16 PM
Rowsej
Rowsej - avatar