用户输入的字符是元音或辅音,使用if else语句

时间:2015-06-05 10:25:29

标签: javascript

请说明代码有什么问题?

=AVG( [Jan],[Feb],[Mar], ....)

1 个答案:

答案 0 :(得分:1)

您的变量名称为chrctr,因此您应该检查chrctr而不是a

<script>
var chrctr = prompt("Enter a character");

    if (chrctr == 'a' || chrctr == 'e' || chrctr == 'i' || chrctr == 'o' || chrctr == 'u') {
        document.write("Is a Vowel");
    }
    else {
    document.write ("Is a consonant");
    }
</script>