The _.shuffle() method shuffles of collection by returning the new array.
Parameters: This method accepts a single parameter as mentioned above and described below:
- collection: This parameter holds the collection to inspect.
Return Value: This method returns the new array after shuffling.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
[4, 1, 3, 2]
Example 2 :
["o", "e", "k", "s", "e", "e", "s", "g", "r", "e", "g", "f", "k"]