repeat string n times javascript

Solutions on MaxInterview for repeat string n times javascript by the best coders in the world

showing results for - "repeat string n times javascript"
Anton
04 Aug 2020
1"a".repeat(10)
Lenzo
20 Apr 2017
1let string = 'Plumbus'
2let count = 3
3
4string.repeat(count); // -> 'PlumbusPlumbusPlumbus'
Niko
01 Aug 2016
1var a="a";
2var aaa=a.repeat(3); // "aaa"
3
Silvia
11 Feb 2016
1function repeatStringNumTimes(string, times) {
2  var repeatedString = "";
3  while (times > 0) {
4    repeatedString += string;
5    times--;
6  }
7  return repeatedString;
8}
9repeatStringNumTimes("abc", 3);
Elisa
02 Jun 2018
1The code below is written using ES6 syntaxes but could just as easily be written in ES5 or even less. ES6 is not a requirement to create a "mechanism to loop x times"
2
3If you don't need the iterator in the callback, this is the most simple implementation
4
5const times = x => f => {
6  if (x > 0) {
7    f()
8    times (x - 1) (f)
9  }
10}
11
12// use it
13times (3) (() => console.log('hi'))
14
15// or define intermediate functions for reuse
16let twice = times (2)
17
18// twice the power !
19twice (() => console.log('double vision'))
queries leading to this page
js get repeated string from stringjs repeat string infinatelymdn string repeatrepeat a string with a loop in javascriptrepeat a certain character nodejsadd a character n times in string jsto repeat a stiring in jsjs equivalent str repeatjavascript string multiplicationhtml write a string multiple timesjavascript multily letterjs repeat html n timesjavascript multiply string by numberhow to make something repeat in javascriptjs print multiple of a stringhow to repeat string in javascriptrepeat method javascriptrepeat character x times javascriptjavascript multiply characterstorepeat javascrtiptstr repeat jsrepeat in javascriptjavascript string char repeat js times string with numberstrint repeatmultiple string length jsjs repeat funcitonrepeat javascript functionrepeat space javascriptmultiply character jstypescript append string times 2string repeat javascript documentation mdnmultiply a string jsjavascript string repeat alternativecopy string num times jsjs run string multiple timesjavascript add multiple characters to stringjavascript print character n timesmultiply character javascriptwrite a function in js that repeat stringrepeat strings x number of times javascriptrepeat addition of str jsjs char multiplyrepeat a character x amount of times in a string jsrepeat a string jstypescript repeat characterextend string with repeated callsconcatenate string number of time javascriptjavascript join string x times repeat until n length javascriptjavscript repeatcheck if text is repeated x times in a row javascriptstring multiplicatoin jsstring repeat 28 29 jsstring from repeated character jsrepeat function n times in x times javascriptrepeat the 2 entries 50 times in jsrepeat n times javascript for injs how to repeat a number 100 timesjavacript repeathow to repeat an amount of times javascripthow to repeat a character n times in javascriptrepeat js 5crepeat a stringprototype object repeatrepeat a string x times javascriptrepeat character n times javascriptstring multiplication jsm repetiion javascripthow to write a function to repeat a stringrepeat a single string multiple times jsjs multiply stringmutliply string jsjavascript repeate js how to to multiply a string set number of times within a single stringrepeat word jsmethod repeat javascripthow to repeat a string in javascriptjs repeat space tumesrepeat letter javascript repeat in jsrepeat method on stringsjavascript string repeat documentationjavascript x times stringrepeat string jsjs repeat functionhow to replicate character in javascriptstringrepeatjavascript repeat 0multiply a char javascriptprint a symbol x amount of times in javascripthow to multiply strings in javascriptrepea javascriptmultiplication string in jshow to repeat a string in python javascriptrepeat the string in javascriptjs repeat html x timesrepeat word 1000 times jsrepeat in javascriptrepeat numbers from 1 to 10 in js as stringhow to repeat a function in an objectreturn string 5 times in javascriptrepeat a word 1000 times with loop in javascriptjs string repeat x timecharacter repeat javascripthow to repeate a letter with for loop jshow to repeat mutipile strings in jsjs string repeatprint a varable n times javascroptrepeats node jshow to repeat text in javascript by multiple timesrepeat a string n times in jsjavascript repeat function every x secondsrepeat a function amount of times jsjavascript repeat charactersrepeat javascript multiple repeating stringjavascript how many times does a digit repeatjavascript string multiplyto loop a string n times in jsjavascript get character x time in stringjavascript repeat wordes6 repeat string n timesjs how to repeat a string in a different fieldrepeats the string a random amount of timesbasic algorithm scripting 3a repeat a string repeat a stringstring repeat in javascriptrepeat a string in javascriptrepeat text javascriptjs repaet console logjs create a string of n spacesjavasceript repeat 3 timeshow to repeat a sentence javascriptjavascript repeat spacehow to repeat string in javascript without repeat funsitonstring repeat 28 29 in jsstring javascript timesrepeat js number of timesrepeat code x times javascriptrepeat string javascript using for looprepeat a string javascript in a plain textjs string multiplicationconsole repeating in jqueryjavascript repeat x timesstring repeat javascript behind the scenesjevascript repeat 4 timesrepeat something x times jshow to use str repeat 282 29 in jsrepeat a character n times javascriptmultiply string in javascriptrepeat stringhow to print string 3 times in jsjavascript repeastring constructor javascript repeat characterrepeat character by positon javascpritmultiplying strings jscan you multiply strin javascriptmultiply string jsjavascript multiply stringswhat does string times string do in jshow many times a string repeats javascriptwrite a function called repeat 2c which accepts a string and a number and returns a new string with the string repeated that number of times javascript repeatmultiply strings in javascripthow to multiply string in javascripthow to repeat strings javascripthow to repeat a string without repeat method in javascriptrepeat string n times javascriptjavascript string repeat 28 29js repeat charmultiply a string a number of times javascriptrepeat charachter for very long timesduplicating a string jsrepeat amount of times javascriptmultiply strings javascriptlog a string x times jsrepat jsjs repeat string charjavascript repeat the same word overhow to repeat a string jshow to repeat first argument for second argument times in jshow to multiply string in reactjs concatenate strings number of timesjavascript repeatstring repeat mdmhow to repeat an argument in jsjavascript string of charactersjs fastest way to get repeated stringsstring repeat javascriptstring times number javascriptjavascript repeat n timesjs concatinate string x timeshow to repeat a character in jacascripthow to repeat a diger dew times jsrepeated string algorythm javascriptjavascript strings how to add a character i timesrepeat for variable number of times javascripthow to repeat a character in javascriptadd 10 times same string javascriptrepeat character in jsstring method that repeats char n times jsjavasxript repearhow to multiply characters in javascriptjavascipt repeatjavascript string repeated charactersstring repeat 28 29 documentation 3ajavascript repeat stringjs repeated stringhot to repeat character n times javascriptstring repeatrepeat function jswrite a function named repeater 28 29 that takes two arguments 28a string and a number 29 2c and returns a new string where the input string is repeated that many times how to repeat string i for loop in javascript 24 22 repeatduplicate string jscounte repeater works in sentence javascriptstring repeat mdnrepeat string function javascriptrepeat char javascriptjavascript repear a stringjavascript repeat a character n timesjs repeat stringconvert repeating index to number jsjavascript string of repeated characters object numberhow to make a repeat in jsjavascript string repeat documentation e2 80 9djavascript generate string of charactersstr repeat jsrepeat string x times javascriptjavascript loop to repeat stringrepeat set amount of times jsrepeat string number of times jsrepeat character javascriptmdn repeathow to multiple each word on string jsrepeat x time jsbasic algorithm scripting 3a repeat a string repeat a string passeddisplay string 2 times javascriptdouble string jsjs multiply char with integerusing string repeat jsrepeat a form n times javascriptprint out a string multiple times javascript for loopsjs string multiplynmultiply strings javastriptreapeat in jsstring repearjs repeat character based on positionrepeat function a number of times javascriptstring repeat loop in javascriptmultiply space in javascriptjavascript string 2a8 times repeat javascriptrepeating a string sepratly 5 times javascriptbuild string js repeat valuesjavascript duplicate string n timesrepeat a char x times javascriptnode repeat string n timeshow to repeat a character a number of times in javascripthow to repeat only one letter in string javascriptjavascript repeat timesjs multiplying a stringmultiply a string like python in jsstring repeat 28 29duplicate string x times javascriptjavascript repeate charrepeat n 28xx 29 5b30 5d in javascriptmultiple string javascriptrepeat variable javascriptstring repeat javascriptvar repeatedstring 3d 22 22 3b while 28times 3e 0 29 7b repeatedstring 2b 3d string 3b times 3b 7d return repeatedstring 3brpeat in javascriptrepeat function javascriptrepeat function in javascripthow to multiply chars jsjavascript repeat string n timesjs string duplicatestring repeat until particular length javascriptrepeat character jscode to get string repeatationreapeate stroingjavascript repeat character in stringstring repeat javascriptdisplaying string multiple times on new line javascriptrepeat a string n times jsstring repeat methodhow do you solve a function that repeats the same wordjavascript generate long stringrepeat a character jsrepeat java scriptjs fill string javascript repeat method mdnjavascirpt insert charanter nuber of timesrepeat string typescripthow to use repeat in javascriptrepeat mdn repeat in javascriptcreate string of repeated characters javascriptreplicate in jsrepeat a string in jsprint repeated character in string javascriptmultiply string javascriptjs repeat char n times in stringjs repeat something 10 timesrepeat space jsrepeat a function for times jsreturn one string that is the given string repeated n times javascriptsrepeat string loop adding one with jsrepeat code 2 times javascriptrepeat something 3 times jsrecurring javascriptjavascript repeat functioncreate repeating letters jsrepaet jsreapeat string jsmdn reapeatjs char repeathow to repeat each character in a string in javascriptconsole log x times based on number jsjavascript repeat charachtermethod to return a string repeated a specified number of timesrepeat 28 29 javascripthow to repeat in javascriptrepeate in jsrepeat 5 times jsjavascript method to repeat an action a given number of timesmultiply char and number javascriptjs repeat string for loopfunction to repeat characterss by number in jsrepeate the string repeat the string in javascriptstring repeatrepeat character in string javascriptrepeat a string certain times js repeat 28 29 jshow to reapeat loop in replace keyword in jqueryrepeat n times a string for a new string javascriptjavascript repeat charhow to repeat a console loghow to remove characters from a string n times javascriptjs multiply lettersjavascript how to repeat indexjs string repeat n timeshow to repeat code in javascript for spammingtypescript repeatcreate repeating chracter jsduplicate a string javascriptrepeat string infinite javascriptalternative methods to repeat 28 29 javascriptjs string repeat in another stringmake a letter repeat in javascriptjavascript repeat characterjavascript repeat character n timesrepeated string javascriptconsole log string 5 timestypescript print value x timesjavascript create string of x charactersrepeated string jsjs print string n timesrepeat 28 29repeat character in javascriptmethod to returns a string repeated a specified number of timesjavascript replicate stringjavascript string of repeated charactersjs multiply stringsjs repeat n timesjs repeat letter timeshow to print a string only one time javascripthow to repeat letter in jshow to repeat javascript objectstring repeat 28 29 maxmultiply a charachter javascript repeat methodhow to print out string 6 times in javascriptjoinstring many times jsrepeat fonciton javascripttext strgin x times jsjs repeat character n timesjavascript concatenate string multiple ltimesjs repeat character x timesstring repeat function in javascriptjavascript get multiple string repeated of indexjs repeatn um timehow to repeat character in string javascriptjavascript multiplying stringshow to return a string x amount in javascriptfunction repeatstringnumtimes 28str 2c num 29 7b return str repeat 28y 29 3b meaninghow to repeat code in javascriptjavascript repeat 5 timesrepeating a string with a for loopwrite a function called repeatstring which repeats the given string src exactly count times in jsmultiply a string in javascriptmultiple letter by int jsrepeat array javascriptcheck repeat time in string jsstring repeat jsstring repeat jsjavascript string repeat run timehow to multiply strings in jsrepeat a string repeat a stringtimes character javascrptrepeat a string n characters long javascripttypescript repetated charactersjs string times numberjs repeat string n timesrepeat command javascriptmultiplying strings javascriptwrite a function called repeat str which repeats the given string src exactly count times string prototype repeat discord jshow to return a string multiple times jshow to return a string x amount in javascript without using repeathow to repeat a string n times in javascriptjs make a strig with repeated charshow eleminate the character repeat in javascriptjs repeat int amount of timesjavascript code in script repeatstring fill jsadd char to string n times jsconcatenate string number of times javascriptjavascript string repeat n times without repeat methodstring times string in jsrepeat javascriptjs multply stringhow to repeat the character of string in jsisrepeated javascriptrepeat characters in a string javascriptjavascript template string duplicatejs repeat function n timesnode js multiply stringsrepeating letters javascriptconcat single character muiltiple times javascriptjs repeat a string n timesrepeat a string n times javascriptreapeat a string till it is n length javascriptmutliply string javascriptrepeat 28 29 jsnodejs repeat string contentjavascript multiple stringjavascript repeat character x number of timesjs repeat string number of times repeat repeat 28 29 method how to make a string repeat jsstring fill js repeat 28 29 javascriptadd string number of time javascriptstring cannot repeat javascriptjavascript repeat string multiple times repeat jsstring repeat 28 29 mndhow to make a string repeat in javascripthow to repeat same string in javascriptjavascript reapeat stringwrite a js program that repeats a given string n number of times write a js function that takes two arguments 3a a string and a positive number n this function repeats the given string n number of times and returns the result string repeat 28how do you multiply a string javascriptstring repeat in es6repeat 10 times for loop javascriptmultiply string number javascriptduplicating a string in javascriptchow to console log a string a certain number of times in jsrepeat something a certain amount of times javascriptrepeat something in javascriptprint string n times javascriptjavascript multiply string by integerjavascript strings multiplyjavascript repeat function n timesjs find repeated stringhow to print one nuber multiple times in javascriptrepeat string javascript for looprepeat x times jsusing reduce to repeat a string in jsjs string repeat repeat 28 29print x amount of characters javascriptrepeat string character javascriptprint string multiple times javascriptjavascript recursion string repeathow to repeat a string with function in javascriptmultiply a string by a number javascriptjavascript method for multiplying string charactersjs 2c repeat stringjavascript string times numberrepeat stringconsole log repeatrepeat times javascriptjs repeat x timesrepeat a string n time nodestring repeat javascripthow to repeat a console by length in jsstr repeatmake a fxn repeat jsjavascript repeat a charachtercreate a string of repeating characters javascriptrepeat a string repeat a string javascriptrepeat string javascriptjavascript string repeatstring repeat jsstr repeat 28this 29how to know repeat character jsrepeating string without repeat 28 29reproduce a string n times jshow to repeat the character in string in javascriptjs repeat charsjavascript repeat methodhow to multiply a string in javascriptrepeat number according to position javascriptnode js repeat x timesmultiply a string javascriptjavascript can you multiply a stringrepeat loop x time javascriptmethod to double letter in string in javascriptrepeat method with template string in jsrecursion repeat char jsrepeat a string a specified times javascriptjavascript repeat function 3 timesrepeat x times javascriptstr repeat in javascriptrepeat function for int times jsrepeat string in javascriptjavascript multiply characterjavascript repeat string x timesjavascript repeating a stringrepeat n times javascriptrepeat methodmultiplying string javascriptjs how to represent 3 repeatingmdn documentation for string repeat 28 29how to repeat characters in javascriptstring multiplication jjsmultiply strings jshjavascipt repeat a stringjavascript how to make a saying repeat 20 timesjs string repeat charadd string a certain amount of times javascripthow to repeat javascript x timesconsole log 28str repeat 283 29 29 3bhow to repeat strings in javascripthow to repeat a function without the repeatjavascript repeat string infinite timesnode repeat stringjs repeatstr repeat javascriptjavascript string repeatjs repeatmdn string repeat 28 29how to repeat a string i jswrite out a string multiple times javascriptrepeat ts functionnodejs string repeatjavascript repeat text n timesfunction repeat 28str 2c time 29multiply string in jshow to times a number by a string js js 2brepeat string n timesjs repeatejs get repeat sringrepeat 10 times javascriptduplicate string javascriptjs compare to same string repeatedlyfor loop repeat stringcan avalues repeat ina set jsstring multiplication javascriptrepeat 28 29 in javascriptjavascript how to multiply a stringjs string timesjavascript string repeat n timesjs repeat methodrepeat method javascritjavascript duplicate stringrepeat a string javascriptjs repeated similar ifrepeat function javascript 8 timesrepeat string char in javacriptjavascript why does my console log repeat multiple timesstring repeat 28 29 mdnprevent same value from repeat javascript apps scriptrepeat a string n times javascript with a for looprepeat character the string in javascriptjavascript function to repeat a text a number of timesrepeat jsrepeat method in javascriptjavascript multiply stringstring to be repeated in jsjavascript repeat a charto repeat individual chaacter in jsjavascript repeat 28 29javascript repeat character n times in stringfunction repeat javascriptrepeat in jsjavascript repeat a function n timesstring repeahow to repeat in javascript for n timesrepeate function in javascriptjavascript repeat char n timesstring repeat ajvascriptrepeat string n times javascript