次のような JavaScript コードを書いています。
function rollTrigger() {
var roll = Math.round(Math.random()*999999999+1);
var result = document.getElementById("result");
if (roll <= 50900000) {
result.innerHTML = "Category 0";
BoLPamount += 1;
document.getElementById("boxlesserprizes").innerHTML = "Box of Lesser Prizes " + BoLPamount;
log.innerHTML += "<br />Trigger - win = true; Category 0"; //LOG
} else if (roll <= 900000) {
result.innerHTML = "Category A";
log.innerHTML += "<br />Trigger - win = true; Category A"; //LOG
} else if (roll <= 360000) {
result.innerHTML = "Category B";
log.innerHTML += "<br />Trigger - win = true; Category B"; //LOG
} else if (roll <= 211890) {
result.innerHTML = "Category C";
log.innerHTML += "<br />Trigger - win = true; Category C"; //LOG
} else if (roll <= 109020) {
result.innerHTML = "Category D";
log.innerHTML += "<br />Trigger - win = true; Category D"; //LOG
} else if (roll <= 56505) {
result.innerHTML = "Category E";
log.innerHTML += "<br />Trigger - win = true; Category E"; //LOG
} else if (roll <= 34888) {
result.innerHTML = "Category F";
log.innerHTML += "<br />Trigger - win = true; Category F"; //LOG
} else if (roll <= 15574) {
result.innerHTML = "Category G";
log.innerHTML += "<br />Trigger - win = true; Category G"; //LOG
} else {
result.innerHTML = "MEH";
log.innerHTML += "<br />Trigger - win = false"; //LOG
};
document.getElementById("roll").innerHTML = roll;
};
しかし、それは正しく機能していません...たとえば、乱数が40200000の場合、想定どおり「カテゴリ0」が表示されますが、乱数が10であっても、「カテゴリG」ではなく「カテゴリ0」が表示されます。何が問題なのですか?