I did a guessing game with the example from video lesson, but if i write the right answer on the third time, it says that i did not guess. The problem is there: if(tryCount == maxTryCount)? This code down below is from lesson.
var answer = parseInt(Math.random() * 100);
var userAnswer = +prompt("Угадай число от 0 до 100");
var maxTryCount = 5;
for(var tryCount = 1; tryCount < maxTryCount; tryCount++){
if(userAnswer == answer){
alert("Поздравляю, ты угадал!");
break;
} else if(userAnswer > answer){
alert("Ты ввёл слишком большое число.");
} else if(userAnswer < answer){
alert("Ты ввёл слишком маленькое число.");
}
userAnswer = +prompt("Попробуй ещё раз. Введи число от 1 до 100\n У тебя осталось " + (maxTryCount - tryCount) + " попыток");
}
if(tryCount == maxTryCount)
alert("Ты проиграл!");
alert("Правильный ответ: " + answer);
I did it! If I change the loop condition to <= and change if(tryCount == maxTryCount) to if(tryCount > maxTryCount) then the third variant is accepted as "right".