0
I wrote a code with intention to obtain two numerical inputs and add them but its not working: pls help var V = prompt("enter V"); var U = prompt("enter U"); var ln = U+V; document.write(ln);
7 Réponses
+ 6
input boxes are elements of html they can be made by simply using input tag. and valueless can be put. you can see codes many codes in sololearn too have it you can see my code too it has input too.
+ 2
they inputs are strings you have to manually set by using par seInt(). this problem appears in prompt use input tag there it converts numbers to integers and it can be custmoized
+ 2
just convert the value obtained in prompt to integer becuase they are string 6 + 6 will show 66 instead of 12.
pa rseInt(6)+ porseInt(6) is 12.
so you can either put them inside prompt() or convert later another thing I suggested was that you can use input boxes instead of prompt you can customize as you like for example see my code validate it and there is no need of conversion
+ 2
This problem doesn't appear when you multiply or divide because those are strictly mathematical operators. + can be used to be perform addition of integers but also be used to combine two strings such as in concatenation.
+ 1
thanks, though I don't understand it properly...
can u pls help me rewrite the code in a way it will work?
I wonder why this problem doesn't come up when am subtracting or multiplying the inputs.
+ 1
pls what are input boxes and how do i use them
+ 1
pls what are input boxes and how do i use them