Slide navigation: Forward with space bar, →, or PgDn. Backwards with ← or PgUp.
Continue with https://hourofcode.com/vidcard. Erase any work you may have and instead start with this code:
var owl = graphic("crazyowl.png")
owl.scale = 0.5
owl.x = 100
owl.y = 0
Now put a second owl to the right.
owl2owl2.x to 200.
Now make four owls.

var n = 100
while (n <= 300)
{
var owl = graphic("crazyowl.png")
owl.scale = 0.5
owl.x = n
owl.y = 0
n = n + 100
}
while?
n = n + 100 to n = n + 0 or n = n, even when editing.
n never reaches 300
You need a different structure for that:
var n = 100
while (n <= 600)
{
if (type == 1)
{
var bug = graphic("ladybug.png")
bug.scale = 0.5
bug.x = n
bug.y = 0
}
else
{
var owl = graphic("crazyowl.png")
owl.scale = 0.5
owl.x = n
owl.y = 0
}
n = n + 100
}
Now you get a bug when the variable type is 1. Otherwise an owl.
type.
Add this line to the top:
var type = 1
type to 2, after a bug was painted.
It's getting tricky. Can you place
type = 2
and
type = 1
into the right spots so that the type changes each time: 1 2 1 2 1 2 ...
Back to just owls. Erase everything. Copy the code from Step 4, but now arrange the owls vertically:

Und schräg?


Tip: Copy the code from Step 4 again. Copy it one more time so you get two rows. Unfortunately on top of each other. Fix the y in the second loop.

For four rows, you could copy again and once again. But why copy when you have loops? Here is a loop that makes many rows. Each row is another loop. A loop in a loop!
var m = 0
var n = 0
while (m <= 400)
{
while (n <= 600)
{
var owl = graphic("crazyowl.png")
owl.scale = 0.5
owl.x = n
owl.y = m
n = n + 100
}
n = 0
m = m + 100
}
Just try it out. And then try bringing the owls closer to each other.
This brain teaser is here because I wasn't sure if any of you are programming geniuses. Don't worry if you have no idea.
Can you alternate owls and bugs, like on a checkerboard?

This was a rapid fire introduction into programming with loops. It is nice that one can explore loops so nicely with JavaScript.
What did we learn?