Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

repeat a function javascript

setInterval(function(){
  console.log("Hello");
  console.log("World");
}, 2000); //repeat every 2s
Comment

string repeat javascript

// best implementation
repeatStr = (n, s) => s.repeat(n);
Comment

string repeat javascript

let text = 'Hello world!';
let result = text.repeat(4);

console.log(result);
Comment

Repeat a String Repeat a String-Javascript

function repeatStringNumTimes(str, num) {
  if (num < 1) {
    return "";
  } else {
    return str + repeatStringNumTimes(str, num - 1);
  }
}
Comment

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 "
Comment

PREVIOUS NEXT
Code Example
Javascript :: http module nodejs 
Javascript :: js fetch status of 500 
Javascript :: javascript escape single quote 
Javascript :: Javascript object convert into JSON 
Javascript :: check web3 metamask disconnect 
Javascript :: javascript console 
Javascript :: react class components 
Javascript :: check if the difference between two dates is more than 1 month in javascript 
Javascript :: change array index position in javascript by up and down click 
Javascript :: paragraph to single line in javascript 
Javascript :: refresh ajax jquery 
Javascript :: js html editor 
Javascript :: javascript check if string ends with space 
Javascript :: mysql_real_escape_string for nodejs 
Javascript :: JavaScript querySelector - By Attribute 
Javascript :: destructuring an object js 
Javascript :: if js 
Javascript :: jquery validate on keyup 
Javascript :: how to restablished closed rxjs websocket 
Javascript :: best reactjs course on udemy 
Javascript :: array of obj to obj with reduce 
Javascript :: js outputting data 
Javascript :: fade in onscroll jquery 
Javascript :: byte number to array js 
Javascript :: start animation with javascript 
Javascript :: array -1 javascript 
Javascript :: check last url in javascript 
Javascript :: split and join in javascript 
Javascript :: how to receive window.postmessage event in angular 9 
Javascript :: remove from string javascript regex 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =