+ 2

i want to get the summation but it concatinate the no so how can i get the sum? var v1=prompt ("enter 1st no"); var v2=prompt ("enter 2nd no"); alert ("Sum="+(v1+v2));

17th Oct 2016, 5:09 AM
Ankit Singh
Ankit Singh - avatar
2 ответов
+ 2
Use the parseInt() function to parse a string into an integer. var v1 = parseInt(prompt("enter 1st no")); var v2 = parseInt(prompt("enter 2nd no")); alert("Sum = " + (v1+v2));
17th Oct 2016, 8:47 AM
Zen
Zen - avatar
+ 1
very very thanks bhai..😊
17th Oct 2016, 6:58 PM
Ankit Singh
Ankit Singh - avatar