JSFiddle - React, Tailwind, and code Playground

by frogggeee McFrogggeee

JavaScript

alert ("this is a password guessing game");
var password = 93749;
var guess = 0;
var triesleft = 3;
var i = 0;
for (i = 0;i < 10;i++) {
if (triesleft != 0) {
	guess = prompt ("guess the password");
  if (guess == password) {
  	alert ("YAY!!! you guessed it right! you won!");
    break;
  } else {
  	alert ("you didn't get it right. try again. you have " + triesleft + " tries left.");
  }
  triesleft = triesleft - 1;
  } else {
  	alert ("you ran out of tries");
  }
}