JSFiddle - React, Tailwind, and code Playground

by LyndseyB

JavaScript

var line = "72 64 150 | 100 18 33 | 13 250 -6";

line = line.split("|");

var item, num, arr = [];

for(var i = 0, len = line.length; i<len; i++) {
    item = line[i];    
    item = item.trim();
    item = item.split(" ");
    
    for(var x = 0, iLen = item.length; x < iLen; x++) {
        if(arr.length < iLen) {
        	arr.push([]);
        }
        num = item[x];        
        arr[x][i] = num;
    }
}

var totals = [];
arr.forEach(function(inner) {
    totals.push(Math.max.apply(Math, inner));    
});

console.log(totals.join(" "));