title: I want the "YOU ENTERED LEVEL X" message to be displayed only once. Please read the full question to understand it better
body: <p>I need help for this code. Let me tell what the problem is. For example, after running the program , if the score is 4, as soon as user scores 4, it will be printed Congratulations!! You entered level 1 of the game and the same goes for level 2 and level 3 for the score 7 and 9 respectively. Now, the problem is- if user scores 4, then the line will be printed for Level 1 and if user fails to answer the next question, then again this line will be printed. What I want is that the line to be printed only once the user enters the score. I don't want it to be printed again and again if the user fails to pass the score for which the message is written. I hope I am able to explain the problem properly. If you don't get what I am trying to say, please tell me. I'll try to explain my problem more elaborately. Thank You. Below is the code</p>
  <pre><code>var readlineSync = require('readline-sync');
  
  var userName = readlineSync.question(&quot;May we know your name please? &quot;);
  
  console.log(&quot;Hello &quot; + userName + &quot; to the neog.camp fun quiz game!!\n&quot;);
  
  console.log(&quot;Please answer 4 questions correctly to reach Level 1 of the game,7 to reach Level 2 of the game, and 9 to reach Level 3 of the game.\nALL THE BEST :) \n\n&quot;);
  
  
  var currentScore = 0;
  var highScores =
  {
    azhar: 10,
    bhargav: 7
  };
  
  function ask(question, answer) {
    var userAnswer = readlineSync.question(question);
    if (userAnswer === answer) {
      console.log(&quot;Correct!!&quot;);
      currentScore++;
      console.log(&quot;score: &quot;, currentScore);
    }
    else {
      console.log(&quot;Wrong!!&quot;);
      console.log(&quot;score: &quot;, currentScore);
    }
    if(currentScore&gt;=4 &amp;&amp; currentScore&lt;5)
       {
      console.log(&quot;Congrats!! You entered LEVEL 1 of the game!!&quot;)
       }
    if(currentScore&gt;=7 &amp;&amp; currentScore&lt;8)
       {
      console.log(&quot;Congrats!! You entered LEVEL 2 of the game!!&quot;)
       }
    if(currentScore&gt;=9 &amp;&amp; currentScore&lt;10)
       {
      console.log(&quot;Congrats!! You entered LEVEL 3 of the game!! Yippeee ;) &quot;)
       }
  }
  
  var questions =
    [
      {
        question: &quot;What is the capital of INDIA? &quot;,
        answer: &quot;New Delhi&quot;
      },
      {
        question: &quot;What is the full name of MS Dhoni? &quot;,
        answer: &quot;Mahendra Singh Dhoni&quot;
      },
      {
        question: &quot;Who founded Amazon ?&quot;,
        answer: &quot;Jeff Bezos&quot;
      },
      {
        question: &quot;Which is the largest country in Asia? &quot;,
        answer: &quot;China&quot;
      },
      {
        question: &quot;How many sides does a quadrilateral have? &quot;,
        answer: &quot;4&quot;
      },
      {
        question: &quot;Which Indian Cricketer did hit six sixes in six balls against England in 2007? &quot;,
        answer: &quot;Yuvraj Singh&quot;
      },
      {
        question: &quot;What is the full form of CS GO? &quot;,
        answer: &quot;Counter Strike Global Offensive&quot;
      },
      {
        question: &quot;How many players are there in a football team excluding the goal keeper? &quot;,
        answer: &quot;10&quot;
      },
      {
        question: &quot;Which language is called the mother of all programming languages?&quot;,
        answer: &quot;C&quot;
      },
      {
        question: &quot;What is the name of the highest mountain in the world? &quot;,
        answer: &quot;Mount Everest&quot;
      }
    ];
  
  for (var i = 0; i &lt; questions.length; i++) {
    var currentQuestion = questions[i];
    ask(currentQuestion.question, currentQuestion.answer);
  }
  
  
  
  console.log(&quot;\nYour final score is : &quot;, currentScore);
  
  if (currentScore &gt;= highScores.azhar) {
    console.log(&quot;Congratulations!! You are the new highest scorer!! \t Kindly send the screenshot of the score to us.\nThank You&quot;)
  }
  else {
    console.log(&quot;Oops!! You failed to beat the highest scorer!!\nBetter Luck Next Time&quot;)
    console.log(&quot;High Scores :- \n&quot; + &quot;Azhar : &quot; + highScores.azhar + &quot;\nBhargav : &quot; + highScores.bhargav);
  }
  </code></pre>