Task: Printing a Sequence
Opgave
Swipe to start coding
Write a JavaScript program which prints the first ten even numbers.
- Create a new
for
loop with the following parameters:- Initialization: Value of
i
initialized to1
. - Condition:
i <= 10
used as the loop condition. - Operation: Value of
i
incremented after every iteration.
- Initialization: Value of
- Use a
console.log
to output the value ofi
multiplied with2
in every iteration. This will give the corresponding even number.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 6. Kapitel 2