0
0
Javascriptprogramming~15 mins

Why JavaScript is widely used - See It in Action

Choose your learning style9 modes available
Why JavaScript is widely used
📖 Scenario: Imagine you want to build a simple webpage that shows why JavaScript is popular. You will create a small program that lists reasons why JavaScript is widely used.
🎯 Goal: Build a JavaScript program that stores reasons why JavaScript is widely used, then displays them one by one.
📋 What You'll Learn
Create an array called reasons with 3 exact reasons as strings
Create a variable called count and set it to 0
Use a for loop with variable i to go through reasons
Print each reason using console.log
💡 Why This Matters
🌍 Real World
JavaScript is used everywhere on the web to make websites interactive and dynamic.
💼 Career
Knowing how to work with arrays and loops in JavaScript is essential for web development jobs.
Progress0 / 4 steps
1
Create the reasons array
Create an array called reasons with these exact strings: 'Runs in browsers', 'Easy to learn', 'Large community'
Javascript
Need a hint?

Use square brackets [] to create an array and separate strings with commas.

2
Add a counter variable
Create a variable called count and set it to 0
Javascript
Need a hint?

Use let to create a variable that can change later.

3
Loop through the reasons
Use a for loop with variable i to go through reasons array
Javascript
Need a hint?

Use reasons.length to get the number of items in the array.

4
Print each reason
Inside the for loop, use console.log to print each reason from reasons using i as the index
Javascript
Need a hint?

Use console.log(reasons[i]) to print each reason.