+ 1
From prompt (which is a string) to value
how to let a prompt be a value
8 Réponses
+ 6
This is makes an integer of the answer.
var value = parseInt(prompt("Enter number: "));
+ 4
It worked perfectly for me. can you link your code?
+ 4
You are using the wrong variable. Amount has the data and you are testing spnd.
var amount=parseInt(prompt("enter an amount of money that is spend"));
if(spnd<0){
alert("cant spend less than nothing");}
else if(spnd>1000000000000){
alert("sorry, but ByteCorp doesn't have that much money");
}
else if(spnd>=0&&spnd<=10000000000000){
+ 3
Roel I did not understand your question.
+ 3
in this case John Wells' answer is correct.
+ 1
John Wells oh sorry already saw it, my mistake. i used the var amount for parseInt and the var spnd to check it🤦🏼♂️
0
//doesnt work.
//code:
var amount=parseInt(prompt("enter an amount of money that is spend"));//i inputted 46
if(amount>=0&&amount<=100){
document.write(amount);}
else{alert("enter a number")}
//alerts: enter a number
0
Ulisses Cruz normally, a prompt(""); is a string
var x = prompt(""); is a string
but i want it to be a value