const notes = [ 'Ab', 'A', 'A#', 'Bb', 'B', 'C', 'C#', 'Db', 'D', 'D#', 'Eb', 'E', 'F', 'F#', 'Gb', 'G', 'G#', ] const directions = ['↑', '↓'] const intervals = ['m6', 'M6'] const getRandomIndex = (arrayParam)=>{ return Math.floor((Math.random()*arrayParam.length)) } const generateQuestion = ()=>{ const note = notes[getRandomIndex(notes)] const direction = directions[getRandomIndex(directions)] const interval = intervals[getRandomIndex(intervals)] return `${note} ${direction} ${interval}`; } document.querySelector('body').innerHTML = generateQuestion()