定义一组函数,输入数字,逆转 并 输出汉字形式:
function reverse() {var num = window.prompt('input');var str = "";for (var i = num.length - 1; i >= 0; i--) {// num.charAt(i);str += transfer(num[i]);}document.write(str);}function transfer(target) {switch (target) {case "1":return "壹";case "2":return "贰";case "3":return "叁";case "4":return "肆";}}
写一个函数,功能是告知你所选定的小动物的叫声:
function scream(animal) {switch (animal) {case "dog":document.write('wang!');return;case "cat":document.write('miao!');return;case "fish":document.write('O~O~o~');return;}}
后续要把web封装的直播课从第一课开始跟着练习.
