【JavaScript】用Switch实现成绩等级判断
let score = prompt("请输入成绩:");//输入成绩 let a = parseInt(score / 10);//将字符串转换为数字 switch (a) { case 6: console.log(`成绩为${score},成绩等级为D`); break; case 7: console.log(`成绩为${score},成绩等级为C`); break; case 8: console.log(`成绩为${score},成绩等级为B`); break; case 9: console.log(`成绩为${score},成绩等级为A`); break; default: console.log(`成绩为${score},成绩等级为E`); break; }
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/14773207.html