Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

while loop

let dice = Math.trunc(Math.random() * 6) + 1;

while (dice !== 6) {
  console.log(`You rolled a ${dice}`);
  dice = Math.trunc(Math.random() * 6) + 1;
  if (dice === 6) {
    console.log(`loop is ended`);
  }
}
Source by sites.google.com #
 
PREVIOUS NEXT
Tagged: #loop
ADD COMMENT
Topic
Name
2+4 =