A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-repeat-method/ below:

Lodash _.repeat() Method - GeeksforGeeks

Lodash _.repeat() Method

Last Updated : 31 Oct, 2023

Lodash _.repeat() method is used to repeat the given string n times.

Syntax:
_.repeat(string, n);
Parameters: Return Value:

This method returns the repeated string.

Example 1: In this example, we are repeating the given string the given number of times by the use of the lodash _.repeate() method.

JavaScript
// Requiring the lodash library  
const _ = require("lodash");

// Use of _.repeat() method 
console.log(_.repeat('#', 4));
console.log(_.repeat('gfg', 3));

Output:

####
gfggfggfg

Example 2: In this example, we are repeating the given string the given number of times by the use of the lodash _.repeate() method.

JavaScript
// Requiring the lodash library  
const _ = require("lodash");

// Use of _.repeat() method 
console.log(_.repeat('GeeksforGeeks', 0));
console.log(_.repeat('_GFG_', 3));

Output:

''
_GFG__GFG__GFG_


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4