JSFiddle - React, Tailwind, and code Playground

by akang2

JavaScript

//Activity 3.7 - keep rolling until...

//This activity is all about 'while' loops. While loops are another kind of loop, just like 'for' loops, but they operate a little differently.

function theRoll() {
    var rolling = Math.floor(Math.random() * 6 + 1);
    return rolling;
}

var dice = 0;

while (dice != 7) {
    var dice = theRoll();
    console.log(dice);
}