// --- Directions
// Write a function that returns the number of vowels
// used in a string. Vowels are the characters 'a', 'e'
// 'i', 'o', and 'u'.
// --- Examples
// vowels('Hi There!') --> 3
// vowels('Why do you ask?') --> 4
// vowels('Why?') --> 0
function vowels(str) {
const matchs = str.match(/[aeiou]/gi);
return matchs ? matchs.length : 0;
} module.exports = vowels;

  

const vowels = require('./index');

test('Vowels is a function', () => {
expect(typeof vowels).toEqual('function');
}); test('returns the number of vowels used', () => {
expect(vowels('aeiou')).toEqual(5);
}); test('returns the number of vowels used when they are capitalized', () => {
expect(vowels('AEIOU')).toEqual(5);
}); test('returns the number of vowels used', () => {
expect(vowels('abcdefghijklmnopqrstuvwxyz')).toEqual(5);
}); test('returns the number of vowels used', () => {
expect(vowels('bcdfghjkl')).toEqual(0);
});

最新文章

  1. 利用xinetd进行时间同步
  2. SAP中需要记住的一些标准表
  3. C#图像处理
  4. libsvm Minist Hog 手写体识别
  5. [git]解决:git config --global push.default matching
  6. 用cryptico.js实现RSA加密(应对cryptico不支持PEM)
  7. gulp browser-sync自动刷新插件
  8. nginx 请求负载 转发规则设置
  9. 《4》CentOS7.0+OpenStack+kvm云平台部署—配置Nova
  10. Navicat连接oracle,出现Only compatible with oci version 8.1 and&nb
  11. hdu 4507 数位dp(求和,求平方和)
  12. iOS有关图片处理的总结 (四)------图片的饱和度,亮度,对照度。
  13. C/C++知识点清单02-上
  14. 用mongo和redis查询排行榜、统计活跃用户
  15. Windows10 永久激活查询/激活时间查询/激活查询命令/激活码查询
  16. echarts柱状图Demo
  17. 一个简单文本分类任务-EM算法-R语言
  18. 【bzoj4066】 简单题
  19. 删除map、list集合元素总结
  20. js布尔值转化

热门文章

  1. AndroidStudio布局编辑器强制刷新布局界面
  2. LUA的table实现
  3. 【转载】SpringBoot-配置发送邮件遇到的一些问题
  4. python学习-2 python安装和环境变量的设置
  5. 3.解决git不可用问题
  6. 后端排序,debug模式中map的顺序出错
  7. 牛客 26C 手铐 (缩环, 树形dp)
  8. Java 同一个类的不同实例对象竟然可以相互访问各自的private成员
  9. 怎样监听HTTP请求的发出与完成
  10. uni-app使用Canvas绘图