Where did I make a mistake?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Where did I make a mistake??

<script> var first = prompt("Enter an integer","0"); var second = prompt("Enter another integer","0"); var s = first + second; var d = first - second; var m = first * second; var q = first / second; document.write("Toplama işleminin sonucu " + s + "<br />"); document.write("Çıkarma işleminin sonucu " + d + "<br />"); document.write("Çarpma işleminin sonucu " + m + "<br />"); document.write("Bölme işleminin sonucu " + q + "<br />"); </script> S is not working. Other operations are working correctly, but addition (var s) is not working. Where did I go wrong? I can't see it. Please help me.

12th Jul 2020, 11:17 AM
Gülefşan
Gülefşan - avatar
1 Answer
+ 5
promt accept input in string farmat.. And addition + operator works as cancatination operation for string.. So you need convert string values to numbers.. Ex: var first= Number(promt("enter")) ; Or just you can use + as +promt("text") ;
12th Jul 2020, 11:27 AM
Jayakrishna 🇮🇳