[Solved] Convert string into several integer arrays [duplicate]


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]]

2

solved Convert string into several integer arrays [duplicate]