If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Using while loops

Problem

Note: the println() function prints out a line of text with the value that you pass to it - so if you say println("Hi"), it will output: Hi
Consider the following code:
var i = 0;
while (i < 3) {
    println("hi");
    i++;
}
What does the code output?
Choose 1 answer:
Choose 1 answer:
Stuck?
Stuck?