1str.split(separator/*, limit*/)
2
3/*Syntax explanation -----------------------------
4Returns an array of strings seperated at every
5point where the 'separator' (string or regex) occurs.
6The 'limit' is an optional non-sub-zero integer.
7If provided, the string will split every time the
8separator occurs until the array 'limit' has been reached.
9*/
10
11//Example -----------------------------------------
12const str = 'I need some help with my code bro.';
13
14const words = str.split(' ');
15console.log(words[6]);
16//Output: "code"
17
18const chars = str.split('');
19console.log(chars[9]);
20//Output: "m"
21
22const limitedChars = str.split('',10);
23console.log(limitedChars);
24//Output: Array ["I", " ", "n", "e", "e", "d", " ", "s", "o", "m"]
25
26const strCopy = str.split();
27console.log(strCopy);
28//Output: Array ["I need some help with my code bro."]