// NUMBER GUESSING GAME const minNum = 1; const maxNum = 100; const answer = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum; let attempts = 0; let guess; let running = true; while(running){ guess = window.prompt(`Guess a number between ${minNum} - ${maxNum}`); guess = Number(guess); if(isNaN(guess)){ window.alert("Please enter a valid number"); } else if(guess < minNum || guess > maxNum){ window.alert("Please enter a valid number"); } else{ attempts++; if(guess < answer){ window.alert("TOO LOW! TRY AGAIN!"); } else if(guess > answer){ window.alert("TOO HIGH! TRY AGAIN!"); } else{ window.alert(`CORRECT! The answer was ${answer}. It took you ${attempts} attempts`); running = false; } } }
@blocso
3 күн бұрын
Great tutorial! I just would like to point out for those like me who tried to integrate with it HTML and CSS, that LOOPS can not be used in that case. Or at least my personal experience. I tried to create an input field and a submit button but in that case I used a SWITCH to make it work.
@ivangerginov5648
8 ай бұрын
Great one! Thanks
@DanielleScott-gh9bi
3 ай бұрын
Wonderful! Thank you!!
@hunin27
8 ай бұрын
Hey bro! I am waiting for other react tutorials or more complex javascript tutorials. I am waiting, no worries and lots of love ❤
@vasimhubli2042
5 ай бұрын
Your tutorials are underrated ❤
@Kh-rf5fk
7 ай бұрын
Hey Bro, thanks for making these tutorials! You make them so easy to understand and follow. Are there also any books or resources you can recommend for further learning?
@RubyDaSnowLeopard
7 ай бұрын
Great explanation 💙
@MzS_92
4 ай бұрын
Thank you!
@Snayder-dk2sn
8 ай бұрын
Please, man , use a dark theme , perhaps , you explain it coolly , I studied html and css now I switched to javascript !
@animehere5955
4 ай бұрын
Just FYI, theres an issue with the code. if we type 50, it recognizes the answer as correct ;=;
@drwajahathussain8455
Ай бұрын
Hi Dear sir how are you doing I want to ask you something, I often forget the java code, what should I do to remember it?
@jamiebenish1534
8 ай бұрын
amazing video 👍🪿
@gibberish00
19 күн бұрын
this code alone is not running. So do i need index.html and style.css for it to run??
@Maskedlapis64
6 ай бұрын
For me the ${} doesn’t do anything, it just prints that
@ARKGAMING
6 ай бұрын
Make sure you're using template literals for your strings if you want it to work(` instead of ' or "), since it's the only string quotes that support this kind of formatting
Пікірлер: 17