How do i break down this " 01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|1 " string into 5 integer arrays ?.
For example:
01|15|59 becomes [01,15,59]
1|47|6 becomes [1,47,6]
How do i break down this " 01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|1 " string into 5 integer arrays ?.
For example:
01|15|59 becomes [01,15,59]
1|47|6 becomes [1,47,6]
var result = string.trim().split(", ").map(el=>el.split("|").map(n=>+n))
this splits the string into an array of these groups ( yet as string )
"1|2, 3|4" => ["1|2","3|4"]
then maps this array to a new array containing the strings splitted and converted to numbers:
=> [[1,2],[3,4]]