@monaka_ben_mezd さんの考え方をベースに。
const scorePatterns = {
AAAA: "5",
AAAB: "5",
AABB: "4",
ABBB: "3",
BBBB: "3",
CBBB: "3",
CCBB: "2"
};
const unknownScore = "不明";
const defaultScore = "1";
function onChangeSelect() {
const q = s => document.querySelector(s);
const scores = [
q('#math').value,
q('#math-a').value,
q('#math-b').value,
q('#math-c').value,
];
let score;
if (scores.includes('noSelect')) {
score = unknownScore;
} else {
const pattern = scores.join('');
if (pattern in scorePatterns) {
score = scorePatterns[pattern];
} else {
score = defaultScore;
}
}
q('#score').innerHTML = score;
}
2Like