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
// See: https://gist.github.com/nealrs/4bdcb6316665338d9a1f7c2b690d6a19 | |
const Excel = require('exceljs'); | |
// create workbook & add worksheet | |
const workbook = new Excel.Workbook(); | |
const worksheet = workbook.addWorksheet('Discography'); | |
// add column headers | |
worksheet.columns = [ |
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
const input = ['AED_AFN', 'ALL_AMD', 'AMD_AFN', 'ALL_GBP']; | |
console.log('input:', JSON.stringify(input)); | |
// somewhat functional, somewhat imperative | |
const collectSymbols0 = pairs => { | |
co |
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
Real-world, little Javascript problem | |
Input is an array of strings. | |
Each string encodes a pair of 3-letter symbols, separated by an underscore '_'. | |
We talk about the left-hand and right-hand symbols that are encoded into the string. | |
E.g. | |
['AED_AFN', 'ALL_AMD', 'AMD_AFN', 'ALL_GBP'] | |
'AED' is the left-hand symbol of the first pair; 'AFN' is the right-hand symbol of the first pair. Etc. | |
We want this data rearranged into an object. |