Pagina de inicio
/
Tecnología
/
Fill in the blank: function main() ( let numRolls = 0; while (true) ( numRolls++; let rollOne = Randomizer nextInt(1.6); let rollTwo = Randomizer nextInt(1,6): console.log("Rolled: "+rollOne +" + rollTwo); if(rollOne ==1 đết rollTwo ==1) ( __ ;lladd a break statement ) ) console.log("It took you"+ numRolls+"rolls to get snake main(): break0 stopo skipo exito

Problemas

Fill in the blank:
function main() (
let numRolls = 0;
while (true) (
numRolls++;
let rollOne = Randomizer nextInt(1.6);
let rollTwo = Randomizer nextInt(1,6):
console.log("Rolled: "+rollOne +" + rollTwo);
if(rollOne ==1 đết rollTwo ==1) (
__ ;lladd a break statement
)
)
console.log("It took you"+ numRolls+"rolls to get snake
main():
break0
stopo
skipo
exito

Fill in the blank: function main() ( let numRolls = 0; while (true) ( numRolls++; let rollOne = Randomizer nextInt(1.6); let rollTwo = Randomizer nextInt(1,6): console.log("Rolled: "+rollOne +" + rollTwo); if(rollOne ==1 đết rollTwo ==1) ( __ ;lladd a break statement ) ) console.log("It took you"+ numRolls+"rolls to get snake main(): break0 stopo skipo exito

Solución

avatar
Adalbertoélite · Tutor durante 8 años
expert verifiedVerificación de expertos
4.7 (263 votos)

Responder

'break'

Explicar

## Step 1<br />The problem is a fill-in-the-blank question related to programming in JavaScript. The code provided is a while loop that continues to execute until a certain condition is met. The condition is that the sum of two random numbers, rollOne and rollTwo, equals 2.<br /><br />## Step 2<br />The while loop is designed to keep running until the sum of rollOne and rollTwo equals 2. This is achieved by incrementing the variable numRolls each time the loop runs.<br /><br />## Step 3<br />The if statement within the while loop checks if the sum of rollOne and rollTwo equals 2. If it does, the loop should stop.<br /><br />## Step 4<br />The blank in the code is where we need to insert the command that will stop the loop. In JavaScript, the command to stop a loop is 'break'.
Haz clic para calificar: