Created
June 13, 2018 03:33
-
-
Save Corbzilla/5dbede1923d640e5d0192e2a54994dff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let input = `NumberA, NumberB, String | |
1, 2, hello | |
2, 4, world | |
3, 6, !` | |
let splitInput = input.split('\n'); | |
let labels = splitInput[0].split(','); | |
let ary = []; | |
for(let i = 1; i < splitInput.length; i++) { | |
let obj = {}; | |
let objData = splitInput[i].split(','); | |
for(let j = 0; j < objData.length; j++) { | |
obj[labels[j]] = objData[j]; | |
} | |
ary.push(obj); | |
} | |
console.log(ary); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment