title: Why does my while loop with an if statement not work properly?
body: <p>i am trying to code a to do list in java script, where a prompt will ask the user what they want to do and then the user has 3 options, either "new" to add a new element or "list" to check the elements already added or "quit" to quit the loop.</p>
  
  <p>i tried changing the syntax by changing the position of the semicolons but it only resulted in a never ending loop which crashes my laptop!   </p>
  
  <pre><code>var todo=[];
  var answer=prompt("what do you want to do?");
  while (answer!=="quit") {
    if (answer=="list") {
      console.log(todo);
    }
    else if (answer="new") {
      var newtodo=prompt("what do you want to add?");
      todo.push(newtodo);
  
  
    }
  }
  alert("ok we're done here");
  </code></pre>
  
  <p>when i open the HTML file that my script is attached to, the first prompt appears as expected, when i type in "quit" it quits the loop as expected and shows the alert but when i type in "new" it keeps asking me what do u want to add? no matter what i type and it just never ends. Also when i type in list it keeps asking me what do u want to add even though it's supposed to list my array. i think i have done a mistake in the syntax but i don't know what.</p>