Created
December 7, 2018 20:09
-
-
Save thall1961/83165b8e0a55bd5b298d2fb2043971b0 to your computer and use it in GitHub Desktop.
convert array values
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
var chordArrays = [ | |
{ | |
'chord type': 'minor', | |
inversion: 'root', | |
chords: [ | |
{ | |
'scale degree': 'II', | |
notes: [1, 3, 5] | |
}, | |
{ | |
'scale degree': 'III', | |
notes: [2, 4, 6] | |
}, | |
{ | |
'scale degree': 'VI', | |
notes: [5, 0, 2] | |
} | |
] | |
}, | |
{ | |
'chord type': 'minor', | |
inversion: 'first', | |
chords: [ | |
{ | |
'scale degree': 'II', | |
notes: [3, 5, 1] | |
}, | |
{ | |
'scale degree': 'III', | |
notes: [4, 6, 2] | |
}, | |
{ | |
'scale degree': 'VI', | |
notes: [0, 2, 5] | |
} | |
] | |
} | |
]; | |
var scale = ['c', 'd', 'e', 'f', 'g', 'a', 'b']; | |
chordArrays.forEach(o => { | |
o.chords.forEach(n => { | |
n.notes = n.notes.map(i => (i = scale[i])); | |
}); | |
}); | |
console.log(chordArrays); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment