Task: Printing a Sequence
Oppgave
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 6. Kapittel 2