+ 1

Problem with code

Hello I have been doing java script a while and I can't make the if ccommand work, if someone better than me is here tell me what I did wrong var answer = prompt("you have 2 gallons left how many miles do you go per gallon", "") <script> if (answer = 25) { document.write("We stopped at a gas station 24 miles away, you get there and recieve 5 gallons") }

17th Apr 2018, 1:15 AM
Supergrupgr
Supergrupgr - avatar
8 Réponses
+ 1
See? It works here. Looking at your code snippet now again maybe the problem is the location of your <script> https://code.sololearn.com/WbDlwIa3Ynyp/?ref=app
17th Apr 2018, 1:28 AM
cyk
cyk - avatar
+ 2
One thing I do know, I think the problem has something to do with line 6 (the one that says if answer = 25)
17th Apr 2018, 1:16 AM
Supergrupgr
Supergrupgr - avatar
+ 1
if (answer == 25)... You probably mistyped it. Should be == not =
17th Apr 2018, 1:16 AM
cyk
cyk - avatar
+ 1
Hum... Let me check something real quick
17th Apr 2018, 1:22 AM
cyk
cyk - avatar
+ 1
There might be something else going on with the rest of the code because it works just fine when I put it in a Script on Code Playground
17th Apr 2018, 1:25 AM
cyk
cyk - avatar
+ 1
k
17th Apr 2018, 1:53 AM
Supergrupgr
Supergrupgr - avatar
+ 1
Please tell me what is on line 38 so I can know where to look 😀
17th Apr 2018, 2:08 AM
cyk
cyk - avatar
0
cyk It still dosen't work.
17th Apr 2018, 1:19 AM
Supergrupgr
Supergrupgr - avatar