Skip to content

Instantly share code, notes, and snippets.

@thall1961
Created December 7, 2018 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thall1961/83165b8e0a55bd5b298d2fb2043971b0 to your computer and use it in GitHub Desktop.
Save thall1961/83165b8e0a55bd5b298d2fb2043971b0 to your computer and use it in GitHub Desktop.
convert array values
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