FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

Problem-Solving/JavaScript/String repeat.md at master · Prosen-Ghosh/Problem-Solving · GitHub

Latest commit

 

History

History
30 lines (22 loc) · 528 Bytes

File metadata and controls

30 lines (22 loc) · 528 Bytes

String repeat Code Wars Problem Solution.

/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/

Problem:

Write a function called repeatStr which repeats the given string string exactly n times.

repeatStr(6, "I") // "IIIIII"
repeatStr(5, "Hello") // "HelloHelloHelloHelloHello"

Solution:

function repeatStr (n, s) {
  return s.repeat(n);
}
  • repeat() Returns a new string with a specified number of copies of an existing string

Back | FazBrowse Home | New Git URL