For example:
const arr = ['ab', 'cdef', 'ghi']
const split = [['a', 'b'], ['c', 'd', 'e', 'f'], ['g', 'h', 'i']]
How can I do that in Javascript? I'm struggling a little. If anyone could help, I would appreciate it.
For example:
const arr = ['ab', 'cdef', 'ghi']
const split = [['a', 'b'], ['c', 'd', 'e', 'f'], ['g', 'h', 'i']]
How can I do that in Javascript? I'm struggling a little. If anyone could help, I would appreciate it.
You can use .map() and Spread Syntax:
const data = ['ab', 'cdef', 'ghi'];
const result = data.map(s => [...s]);
console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }