GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — JavaScript String repeat() Method - GeeksforGeeks JavaScript String repeat() MethodLast Updated : 11 Jul, 2025 The Syntax:string.repeat(count);Parameters:This method accepts a single parameter.
Return values:It returns a new string that contains the specified number of copies of the string. Example 1: Repeating a String Twice Using repeat() The code repeats the string "forGeeks" two times using the repeat() method, creating a new string "forGeeksforGeeks". This method returns a new string with the original string repeated the specified number of times.
Output forGeeksforGeeks Example 2: Repeating a String Five Times Using repeat() The code repeats the string "gfg" five times using the repeat() method, resulting in the string "gfggfggfggfggfg". This method returns a new string with the original string repeated the specified number of times.
Output gfggfggfggfggfg Example 3: Repeating a String Two Times Using repeat() The code repeats the string "gfg" two times using the repeat() method. Even though the repeat count is 2.9, it's converted to 2, resulting in "gfggfg" as the output.
Output gfggfg We have a complete list of Javascript string methods, to check those please go through this Javascript String Complete reference article. Supported Browsers:Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |