How to print a word 100 times in Javascript?

I am gonna show you three methods to print a word 100 times in Javascript.
Let’s greet a person 100 times.

Using for loop:

for(var i = 1; i < 101; i ++)
  {
    console.log("Hello")
  }

Using while loop:

var i = 1
while(i < 101)
  {
    console.log("Hello");
    i = i + 1;
  }

Using repeat() function:

var x = "hello\n".repeat(4)
console.log(x)
Facebook
Twitter
LinkedIn
Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

ABOUT ME !!
Johan William

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

RECENT POSTS

TEST