-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
48 lines (36 loc) · 907 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function init() {
next();
}
window.onload = init;
function next() {
document.getElementById("exercise").textContent = randomExercise();
document.getElementById("position").innerHTML = randomPosition();
document.getElementById("next").focus();
}
function random(n) {
return Math.floor(Math.random()*(1+n));
}
function randomPosition() {
return 1 + random(4);
}
function randomScale() {
return scales[random(3)];
}
function randomLetter() {
return letters[random(6)];
}
function randomAccidental() {
return accidentals[random(2)];
}
function randomExercise() {
return randomLetter() + randomAccidental() + " " + randomScale() + " scale";
}
var scales = [
"minor",
"major",
"minor pentatonic",
"major pentatonic"
]
var positions = [1, 2, 3, 4, 5]
var letters = ["A", "B", "C", "D", "E", "F", "G"]
var accidentals = ["", "\u266f", "\u266d"]