Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Task: Printing a Sequence | Discovering Loops
Introduction to JavaScript

Swipe to show menu

book
Task: Printing a Sequence

Task

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 to 1.
    • Condition: i <= 10 used as the loop condition.
    • Operation: Value of i incremented after every iteration.
  • Use a console.log to output the value of i multiplied with 2 in every iteration. This will give the corresponding even number.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 6. ChapterΒ 2

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

book
Task: Printing a Sequence

Task

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 to 1.
    • Condition: i <= 10 used as the loop condition.
    • Operation: Value of i incremented after every iteration.
  • Use a console.log to output the value of i multiplied with 2 in every iteration. This will give the corresponding even number.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 6. ChapterΒ 2
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt