Repeating the text N times

Asked 2 years ago, Updated 2 years ago, 18 views

In Perl, if you want to repeat a text N times, you can do $a = "a" x 10; aaaaaaaa' It's like this, but is there anything like this in JavaScript?

javascript

2022-09-22 21:59

2 Answers

Array(11).join("a") //"aaaaaaaaaa"


2022-09-22 21:59

"a".repeat(10) // "aaaaaaaaaa"


2022-09-22 21:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.