1const string = 'hi there';
2
3const usingSplit = string.split('');
4const usingSpread = [...string];
5const usingArrayFrom = Array.from(string);
6const usingObjectAssign = Object.assign([], string);
7
8// Result
9// [ 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e' ]
10
1 var word = userInput[0];
2 var l = word.split("");
3 console.log(l);
4
5//input abb
6//op ['a','b','b']
1const string = 'word';
2
3// Option 1
4string.split('');
5
6// Option 2
7[...string];
8
9// Option 3
10Array.from(string);
11
12// Option 4
13Object.assign([], string);
14
15// Result:
16// ['w', 'o', 'r', 'd']
17
1let input = "words".split("");
2let output = [];
3input.forEach(letter => {
4 output.push(letter.charCodeAt(0))
5});
6console.log(output) //[119, 111, 114, 100, 115]