Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You've just had a few small-ish syntax errors in your code. This works for me:</p> <pre><code>function playGame() { test=document.getElementById("game"); var userInput=gameInput=document.getElementById("gameInput").value; if (test.innerHTML=="\"Question_1\"") { if (userInput.toLowerCase()=="yes") { test.innerHTML="Ending_Result_1"; } else if (userInput.toLowerCase()=="no") { test.innerHTML="\"Question_2\""; } else { test.innerHTML="Ending_Result_2"; } } else if (test.innerHTML=="\"Question_2\"") { if (userInput.toLowerCase()=="yes") { test.innerHTML="Positive_Ending"; } else if (userInput.toLowerCase()=="no") { test.innerHTML="Ending_Result_3"; } else { test.innerHTML="Ending_Result_4"; } } else { test.innerHTML="Refresh_page_message"; } } </code></pre> <p>I've took the liberty of re-formatting the code to suit my style better (not to suggest there's something wrong with yours, but to be able to see where you've omitted closing parentheses). Basically, you haven't closed one conditional statement, and you didn't close the whole inner block before your last <code>else</code> either. That threw an error of <em>'playGame is not defined'</em> in the debugger.</p> <p>Another point, but not why the code doesn't compile, is that you're not including <code>"</code> quote sign as a string literal in your conditions, where it's a part of your innerHTML contents. Your comparisons would have to look like this: <code>test.innerHTML=="\"Question_1\""</code> where <code>\</code> <em>'backslash'</em> marks a single next character as a string literal to the compiler. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload