在这里寻找一些建议来改进我的编码。
你如何使这段代码更短/更有效?
var resultsConstructionYear = readCookie('constructionYear');
if (resultsConstructionYear == 3) {
document.getElementById('resultsUserConstructionYear').innerHTML = "Avant 1944";
} else if (resultsConstructionYear == 4) {
document.getElementById('resultsUserConstructionYear').innerHTML = "Entre 1945 et 1974";
} else if (resultsConstructionYear == 5) {
document.getElementById('resultsUserConstructionYear').innerHTML = "Entre 1975 et 1989";
} else if (resultsConstructionYear == 6) {
document.getElementById('resultsUserConstructionYear').innerHTML = "Entre 1990 et 2009";
} else if (resultsConstructionYear == 7) {
document.getElementById('resultsUserConstructionYear').innerHTML = "Après 2010";
} else {
document.getElementById('resultsUserConstructionYear').innerHTML = "Inconnue";
}
Run Code Online (Sandbox Code Playgroud)