print () is a function whose purpose is to print a document, you must use console.log () to display it on the console.
Put a boolean in front of your loop, for example var eightAppear = false
Your state now looks like do {... }while(!eightAppear)
Then, a random number from 0 to 9 is generated inside your loop. Math.floor(Math.random()*10) your string. If the number is 8 change values ββfrom eightAppear to true
Since this seems to be an exercise, I will let you code it, now should not be difficult :)
source share