title: Simple JavaScript function that asks the user for correct answer only 5 times?
body: <p>I am trying to develop a very simple function with JavaScript that prompts the user to input a number, and then gives them 5 chances to guess the square of the given number. </p>
  
  <p>So for example, if the user puts in 6 in the first prompt, they should put in 36 in the second prompt, but if they fail to make it right, they are getting an error saying that the guessed number is wrong. And they are limited to only 5 chances, so after that, the program does not prompt a user again. </p>
  
  <p>I tried to do something like this to keep things simple:</p>
  
  <pre><code>var input = parseInt(window.prompt("Enter a number", "Enter here"));
  var input2 = parseInt(window.prompt("Guess its square now in 5 tries");
  if (input2 == input*input) {
      alert("Good!");
  } else {
      prompt("Wrong, enter again!");
  }
  </code></pre>
  
  <p>Am I on a right path here? I mean it is not doing what I want it to do, but I am really stuck at this point. Have no idea how to loop it 5 times, or what to do next. </p>