Please keep in mind that I'm a beginner with JavaScript.
I am experiencing some problems with a simple code in JavaScript. What I am trying to accomplish is a While loop, that will continuously ask the user to "Enter name" unless the Prompt box is empty OR the user selects cancel.
When I hit cancel or type in nothing and hit OK, the while loop still executes, and from the specified conditions I can't figure out why.
I also thought this may be because it is not recognizing what the var "userInput" is so I tried declaring it outside the loop.
Here is my code. Any help is appreciated.
var userInput;
while(userInput =! null || userInput != ""){
userInput = prompt("Enter name","");
var array = [userInput];
document.write(array.sort() + "<br />")
}