Created
May 25, 2017 09:21
-
-
Save elct9620/c70f3faa7f0e7505f6ebba84fefd0d59 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function RawToBook(raw) { | |
var columns = raw.split(','); | |
return { | |
IBSN: columns[0], | |
Title: columns[1], | |
Author: columns[2], | |
Press: columns[3], | |
Class: columns[4], | |
Description: columns[5], | |
}; | |
} | |
function ParseStringToBooks(raw) { | |
if(raw.length == 0) { | |
return; | |
} | |
var rows = raw.split(';'); | |
return rows.map(RowToBook); | |
} | |
var books = ParseStringToBooks(input); | |
// books[0].IBSN => 123456 | |
// books[1].Title => "XXXXX" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment