0 of 8 problems solved • 0%
Use in a course

Exercise prompt

Trace a while Loop

A while loop repeats as long as its condition is true. Code inside the loop must eventually change the value used by that condition.

Example

let lives = 2; while (lives > 0) { console.log("Lives:", lives); lives -= 1; }

Your task

Read the battery loop and predict the value of battery after it finishes. Replace the empty prediction while keeping the loop and Actual: line unchanged.

Hint

Check the condition again after each update.