How to make sure that after each wrong age he displays the window "сколько мне лет?" until the test person guesses?

 <script> var a=prompt("Сколько мне лет?"); var b=28; var b=a; while(b<28) { alert("побольше"); a++; } </script> 

    5 answers 5

    1. To make an algorithm
    2. Write code

    Let's start with the first.

    1. Ask "How old are I?"
    2. If the answer is greater than the value, output "More". Return to step 1.
    3. If the answer is less than the value, output "Less". Return to step 1.
    4. If the answer is equal to the value, output "Guess". To finish

    Second point:

     var trueAnswer = 28; var answer; do{ answer = prompt("Сколько Вам лет?"); if ( answer < trueAnswer ) alert("Больше"); else if ( answer > trueAnswer ) alert("Меньше"); }while ( answer != trueAnswer ) alert("Угадали!"); 

    • Thank you! That was what I was waiting for! They wrote about explained !!! - Verzilamv
     function HowMuch(){ prompt('Возраст?') == 28 ? alert('Верно!') : HowMuch(); } HowMuch(); 

       function foo() { var a = prompt("Сколько мне лет?"); if (a < 28) { alert("больше") foo(); } else if (a > 30) { alert("меньше") foo(); } else { alert("угадал!!!") } } foo(); 

         var old = 28; var stop = false; while (!stop) { var a = prompt("Сколько мне лет?"); if a = b { alert("Правильно!"); stop = true; } else { alert("Попробуй еще раз!"); } } 

        • does not work!!!! - Verzilamv

         while(prompt("Сколько Вам лет?") != 28) alert("Неверно"); 

        • does not work!!!! - Verzilamv
        • @Verzilamv what exactly does not work? - torokhkun
        • @torokhkun, "person is not defined" - HamSter
        • @Verzilamv agrees, I did not rewrite it, it is already working. Although you are already filled up with examples :) - torokhkun
        • thanks for the help! - Verzilamv