js repeat
let string = 'Plumbus'
let count = 3
string.repeat(count); // -> 'PlumbusPlumbusPlumbus'var a="a";
var aaa=a.repeat(3); // "aaa"
// best implementation
repeatStr = (n, s) => s.repeat(n);function repeatStringNumTimes(string, times) {
var repeatedString = "";
while (times > 0) {
repeatedString += string;
times--;
}
return repeatedString;
}
repeatStringNumTimes("abc", 3);setInterval(function(){
console.log("Hello");
console.log("World");
}, 2000); //repeat every 2sfunction repeatStr (n, s) {
return s.repeat(n)
}
/////////////////////////////similar///////////////////////////////////////////
repeatStr = (n, s) => s.repeat(n);
Also in JavaScript:
- js use await in synchronous method
- express ssl
- splice()
- how to disable time option in select jquery
- how do i set an id for a div in js
- how to install popper.js in angular 9
- how to move an element of an array in javascript
- js percorrer objeto
- speech to text in js
- npm md to html
- remove backslash in json array javascript
- download image in nodejs
- como percorrer um objeto js
- async await iife
- array of array key value javascript
- how to add array numbers in javascript
- add countdown timer to javascript quiz
- how to wirte json format
- loading screen fivem js
- How to replace an array vue.js
- form validation for email in js
- nodejs config file
- react responsive video player
- react arrays