1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
let body = document.body;
let doc = {};
body.querySelectorAll('[id]').forEach(e => doc[e.id] = e);
let rand = x => Math.floor(Math.random() * x);
let arand = a => a[rand(a.length)]
let roots = [
"A", "B", "C", "D", "E", "F", "G",
"A#", "C#", "D#", "F#", "G#",
"Ab", "Bb", "Db", "Eb", "Gb",
];
let modes = [
"major",
"natural minor", "harmonic minor", "melodic minor",
];
let random_scale = () => `${arand(roots)} ${arand(modes)}`;
doc.scale_btn.onclick = () => doc.scale.innerHTML = random_scale();
doc.scale_btn.onclick();
|