Javascript, How do I give three attempts only to the userInput using do while | Sololearn: Learn to code for FREE!

+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)

1/2/2021 12:38:10 PM

Odai Qudah

4 Answers

New Answer

+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!

+1

Lothar, Thanks i didn't know , any how i will add my code please check it

+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);

+1

After all it was easy 😅