split(separator, limit): The split() function is used to split the data depending upon the attributes we are passing in it. The separator attributes specify that from this word/sign the string will be divided. The limit attribute is optional, it specifies how many splits will be there.
In this, when we will click on the “Go” button the array of the multiline string will be displayed on the screen separated by “,”.
Example 2: Now, let’s see how to get a particular index of an array.
As we wrote array, hence only the 2nd line has been printed. If we will write array, then it will be undefined as this array contains data in the first two indexes only that are 0 and 1 respectively.
Example 3: Now, let’s try to take string as an user input.