The _.repeat()
function from lodash is used to repeat a given string a specified number of times. It takes in two arguments: the string to be repeated and the number of times to repeat the string. Here is an example of using the _.repeat()
function in JavaScript with lodash:
index.tsx126 chars5 lines
In the example above, we import lodash using const _ = require('lodash')
and then use the _.repeat()
function to repeat the string 'abc' three times. The resulting output is 'abcabcabc'.
Note that _.repeat()
function can also be used with other data types such as numbers and arrays.
gistlibby LogSnag