Answers for "repeat in es6 javascrippt"

2

repeat a function javascript

setInterval(function(){
  console.log("Hello");
  console.log("World");
}, 2000); //repeat every 2s
Posted by: Guest on November-25-2020
0

javascript repeat function

/* The string.repeat(n) method constructs and returns a new string
with "n" number of copies. */

const chorus = "Because I'm happy. ";
console.log(`Chorus lyrics: ${chorus.repeat(3)}`);
// → "Chorus lyrics: Because I'm happy. Because I'm happy. Because I'm happy. "

// Use within a function
greeting = (n, words) => words.repeat(n);
console.log(greeting(5, "howdy ")); 
// → "howdy howdy howdy howdy howdy "
Posted by: Guest on February-26-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language