javascript - 元音没有被过滤掉
问题描述
只是学习 JavaScript 的基础知识并尝试从字符串中去掉元音:
function disemvowel(str) {
let no_vowels = '';
for (let a = 0; a < str.length; a++) {
if (str[a] !== 'a' || str[a] !== 'A' || str[a] !== 'i' ||
str[a] !== 'I' || str[a] !== 'o' || str[a] !== 'O' ||
str[a] !== 'u' || str[a] !== 'U' || str[a] !== 'e' ||
str[a] !== 'E') {
// if none of the above is in the index add it to no_vowels
no_vowels += str[a];
}
}
return no_vowels;
}
字符串不变。为什么 ?
解决方案
推荐阅读
- c# - 如何从 IDL 文件生成 c# 文件?
- html - 使用 flex 防止兄弟姐妹被推送
- django - 如何列出自定义目录的所有文件
- angular - 为 angular5 项目集成 AppLozic 聊天插件
- forms - Mozilla 上的重力表单复选框渲染
- c++ - 是否有任何直觉知道一个方法是否会返回一个迭代器或一对?
- redux - 未调用 MapStateToProps
- angular - ngx-leaflet 层的渲染中显示的白线
- python - 将具有多个键的 Python 字典映射到具有多个匹配键的列的数据框中
- python - BeautifulSoup - 解析文件中的数值