I am making a little test that people can use to check their knowledge of hiragana.
It randomly selects 4 hiragana from a 2nd array and one correct spelling of the hiragana.
It looks pretty much exactly as it should with one twist. The correct answer is in the same place every time! The second hiragana always shows as correct. This is the code that I have used to randomise. Thanks in advance for your help!
var first = Math.floor((Math.random() * 46));
var second = Math.floor((Math.random() * 46));
var third = Math.floor((Math.random() * 46));
var fourth = Math.floor((Math.random() * 46));
var selector = Math.floor((Math.random() * 4));
var firstHiragana = hiraganaSet[first][0];
var secondHiragana = hiraganaSet[second][0];
var thirdHiragana = hiraganaSet[third][0];
var fourthHiragana = hiraganaSet[fourth][0];
alert(selector)
if (selector = 0){
var romaji = hiraganaSet[first][1];
var romajiData = hiraganaSet[first][0];
}
else if (selector = 1){
var romaji = hiraganaSet[second][1];
var romajiData = hiraganaSet[second][0];
}
else if (selector = 2){
var romaji = hiraganaSet[third][1];
var romajiData = hiraganaSet[third][0];
}
else if (selector = 3){
var romaji = hiraganaSet[fourth][1];
var romajiData = hiraganaSet[fourth][0];
}