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

repeat string in 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 :: print string multiple times in javascript 
Javascript :: js class private 
Javascript :: $.ajax how to read data vale in controller in rails 
Javascript :: import npm module node.js 
Javascript :: navbar route with params vue 
Javascript :: array.splice javascript 
Javascript :: capitalize each word from string in react 
Javascript :: node cron schedule specific time 
Javascript :: add color to attribute using jquery 
Javascript :: how to return argument in javascript 
Javascript :: express prisma 
Javascript :: javascript error try catch 
Javascript :: js object.entries with sort 
Javascript :: invariant failed: you should not use <link outside a <router 
Javascript :: end session express 
Javascript :: js array .filter 
Javascript :: isotope js 
Javascript :: js remove escape characters from json 
Javascript :: how to set selected value of dropdown in javascript 
Javascript :: js commenst 
Javascript :: remove duplicate values from array 
Javascript :: yarn globakl 
Javascript :: express route parameters 
Javascript :: how to find missing number in integer array of 1 to 100 in javascript 
Javascript :: spinner react native 
Javascript :: how to add onclick to child element created javascript 
Javascript :: node js version 14 
Javascript :: file download jquery 
Javascript :: js reduce example 
Javascript :: for each array 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =