+ 6

Is there an easy way to repeat a char n times in javascript without the use of a function?

26th Nov 2016, 1:29 PM
TheOtherOne
TheOtherOne - avatar
4 Réponses
+ 7
@Sandeep Chatterjee I meant: without writing a function on my own that would obviously contain loops...
26th Nov 2016, 3:24 PM
TheOtherOne
TheOtherOne - avatar
+ 6
Well, I actually found a way: Array(n+1).join("a") results in "aaaaaaa" (n times)
26th Nov 2016, 1:35 PM
TheOtherOne
TheOtherOne - avatar
+ 1
that's great nice but loops are not function the join() is a function does this works
26th Nov 2016, 1:54 PM
Sandeep Chatterjee
+ 1
ok it is nice 😀
27th Nov 2016, 11:39 AM
Sandeep Chatterjee