|
| 11 Sep 2015 11:52 AM |
var name = prompt("Hello, what is your name?") alert("Hello, " + name + "."); alert("You have a knife during the school lesson,") var answer = prompt("what do you do? (type the answer letter) A: Hide it - B: Tell the teachers C: Call your parents and go home"); if (answer === "A") { alert("Wow, nice answer but you could have done better.") }; if (answer === "B") { alert("No, what a mistake! They could suspend you from school.") }; if (answer === "C") { alert("Ok, but now get ready to answer their questions.") }; |
|
|
| Report Abuse |
|
|
TraciLaci
|
  |
| Joined: 08 Sep 2015 |
| Total Posts: 87 |
|
|
| 11 Sep 2015 11:53 AM |
| You shouldn't put three "ifs" in a row. Use else-ifs or a switch statement. |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Sep 2015 11:55 AM |
Better off using == instead of ===
Unless you want it to match exactly the same use === |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2015 11:56 AM |
| oops i didn't put a "-" after "teachers" in the second prompt |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2015 11:57 AM |
3many viruses or what im too scared to run it |
|
|
| Report Abuse |
|
|
TraciLaci
|
  |
| Joined: 08 Sep 2015 |
| Total Posts: 87 |
|
|
| 11 Sep 2015 11:57 AM |
@gmv
But it's less efficient.
Also use String.toUpperCase() so the user can type in the letters in any case. |
|
|
| Report Abuse |
|
|
| |
|