function isVowel(char){
if(typeof char == 'string' && char.length > 1){
console.log('not a char');
return 'not a char';
} else {
if (char.toLowerCase() === ('a'||'e'||'i'||'o'||'u')){
console.log(char, true);
return true;
} else {
console.log(char, false);
return false;
}
}
}
document.writeln(isVowel('a'));
document.writeln(isVowel('e'));
document.writeln(isVowel('l'));
the result is: true, false, false;
it should be: true, true, false;
Can anyone help me why this is happening?
I'm just barely learning JavaScript...
Also, is there any way to refactor this code? I don't want to be repeating myself for every new condition..