Categories: Uncategorized

Javascript – Simple For Loop Examples

These are some examples of simple for loop challenges and exercises I did for fun.

// Print 'hello' the string vertically
var str = 'hello';
for(var count = 0; count < str.length; count++) {
 console.log(str[i])
}
// print all numbers between -10 and 19

for(var i = -10; i < 20; i++) {
 console.log(i)
}

// print even numbers between 10 and 40

for(var i = 10; i < 40; i++) {
 if(i % 2 === 0){
 console.log(i)
 }
}
// print all odd numbers between 300 and 333
for(var i = 300; i < 333; i++) {
 if(i % 3 === 0){
 console.log(i)
 }
}
// print all numbers divisible by 5 and 3 between 5 and 50
for(var i = 5; i < 50; i++) {
 if(i % 3 === 0 && i % 5 === 0) {
 console.log(i)
 }
}
Admin

Recent Posts

Unveiling the Intricacies of the Tinder Algorithm: 5 Surprising Metrics

Monitored by Tinder The inner workings of the Tinder algorithm remain shrouded in secrecy, known…

1 month ago

Is Shopping Temu Safe

Use fav19073 30% OFF Shop Now I recently had a fantastic buying experience on Temu,…

4 months ago

Cheap Netflix Subscription

Unlocking Affordable Streaming: How Gamsgo.com is Revolutionizing Netflix Subscriptions Sign Up Save1 coupon code for…

5 months ago

Domains for SALE.

razerkeyb.com gloriousmouse.com

9 months ago

How to Start your own vegetable garden?

Planting your own vegetables and fruit is a great way to save money and eat…

1 year ago

Jobs AI can’t replace

While AI has the potential to automate many tasks, there are still some jobs that…

1 year ago