+ 1

Javascript, How do I give three attempts only to the userInput using do while

I want to make the user guess one of two numbers and I will let him try only three times, my array contain 6 numbers and I'm using (do , while)

2nd Jan 2021, 12:38 PM
Odai Qudah
Odai Qudah - avatar
4 Réponses
+ 6
Odai Qudah before we can help you, you should show us your attempt first. if you have not done a try by yourself upto now, please do so. Put your code in playground and link it here. without having seen your code, you can only get a hint of how it could be done: ▪︎ use a loop with a counter variable that will be decremented in each iteration. this variable can be checked with s conditional expression e.g. if..., Thanks!
2nd Jan 2021, 1:22 PM
Lothar
Lothar - avatar
+ 1
Lothar, Thanks i didn't know , any how i will add my code please check it
2nd Jan 2021, 1:36 PM
Odai Qudah
Odai Qudah - avatar
+ 1
var me = '3'; var tryGuess = ['1', '3','5','7']; do{ tryGuess = prompt('how many times i tryied to fix this assignment?from 1 to 10'); me <= 4; }while(tryGuess !== me){ alert("correct"); } console.log(tryGuess);
2nd Jan 2021, 1:37 PM
Odai Qudah
Odai Qudah - avatar
+ 1
After all it was easy 😅
6th Jan 2021, 9:52 PM
Odai Qudah
Odai Qudah - avatar