JavaScript while Loop
Certainly! Here's an example of a while loop in Objective-C:
int i = 0;
while (i < 5) {
NSLog(@"The value of i is %d", i);
i++;
}
And here's an example of a while loop in JavaScript:
let i = 0;
while (i < 5) {
console.log(`The value of i is ${i}`);
i++;
}
These examples demonstrate how to use a while loop to iterate a block of code as long as a certain condition is true. In both cases, the loop will continue executing the code inside the curly braces until the condition i < 5
becomes false. Each time the loop iterates, the value of i
is printed to the console.
I hope this example is helpful!