// --- 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);
});

[Algorithm] Find The Vowels的更多相关文章

  1. Java Algorithm Problems

    Java Algorithm Problems 程序员的一天 从开始这个Github已经有将近两年时间, 很高兴这个repo可以帮到有需要的人. 我一直认为, 知识本身是无价的, 因此每逢闲暇, 我就 ...

  2. 挑子学习笔记:两步聚类算法(TwoStep Cluster Algorithm)——改进的BIRCH算法

    转载请标明出处:http://www.cnblogs.com/tiaozistudy/p/twostep_cluster_algorithm.html 两步聚类算法是在SPSS Modeler中使用的 ...

  3. PE Checksum Algorithm的较简实现

    这篇BLOG是我很早以前写的,因为现在搬移到CNBLOGS了,经过整理后重新发出来. 工作之前的几年一直都在搞计算机安全/病毒相关的东西(纯学习,不作恶),其中PE文件格式是必须知识.有些PE文件,比 ...

  4. [异常解决] windows用SSH和linux同步文件&linux开启SSH&ssh client 报 algorithm negotiation failed的解决方法之一

    1.安装.配置与启动 SSH分客户端openssh-client和openssh-server 如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有 ...

  5. [Algorithm] 使用SimHash进行海量文本去重

    在之前的两篇博文分别介绍了常用的hash方法([Data Structure & Algorithm] Hash那点事儿)以及局部敏感hash算法([Algorithm] 局部敏感哈希算法(L ...

  6. Backtracking algorithm: rat in maze

    Sept. 10, 2015 Study again the back tracking algorithm using recursive solution, rat in maze, a clas ...

  7. [LeetCode] Reverse Vowels of a String 翻转字符串中的元音字母

    Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...

  8. [Algorithm & NLP] 文本深度表示模型——word2vec&doc2vec词向量模型

    深度学习掀开了机器学习的新篇章,目前深度学习应用于图像和语音已经产生了突破性的研究进展.深度学习一直被人们推崇为一种类似于人脑结构的人工智能算法,那为什么深度学习在语义分析领域仍然没有实质性的进展呢? ...

  9. [Algorithm] 群体智能优化算法之粒子群优化算法

    同进化算法(见博客<[Evolutionary Algorithm] 进化算法简介>,进化算法是受生物进化机制启发而产生的一系列算法)和人工神经网络算法(Neural Networks,简 ...

随机推荐

  1. 分享 Shiro 学习过程中遇到的一些问题

    最近在学习 shiro 安全框架后,自己手写了一个小的管理系统 web 项目,并使用 shiro 作为安全管理框架.接下来分享一下在这过程中,遇到的一些问题以及自己的解决思路和方法. 一.Log ou ...

  2. Redis 和 Memcached 各有什么优缺点,主要的应用场景是什么样的?

    1.显示最新的项目列表 2.删除与过滤 3.排行榜相关 4.按照用户投票和时间排序 5.处理过期项目 6.计数 7.特定时间内的特定项目 8.实时分析正在发生的情况,用于数据统计与防止垃圾邮件等 9. ...

  3. 封装PHP增删改查方法

    <?php class sqlModel{ public $db; public function __construct(){ try{ $dbms='mysql';//数据库类型 $dbNa ...

  4. iframe/frameset/frame的区别

    目录 iframe iframe属性的用法 iframe属性的取值 iframe的书写格式 frameset frameset的用法(框架模板) frameset属性的属性值 frame frame的 ...

  5. 用shell脚本安装MySQL-5.7.22-官方版本

    Install_CentOS7_MySQL57_binary.sh #!/bin/bash MySQL_Package=mysql-5.7.22-linux-glibc2.12-x86_64.tar. ...

  6. ide的debug

    webstom 新建立一个配置项 找到webpack.config.js,最后一行加上 devtool: "source-map" 然后点击debug

  7. 搭建Leanote网络云笔记

    下载启动 MongoDB Leanote 依赖 MongoDB 作为数据存储,下面开始安装 MongoDB: 下载 MongoDB 进入 /home 目录,并下载 MongoDB: cd /home ...

  8. .Net C# 读取xml

    [TestMethod] public void Test3() { StringBuilder temp = new StringBuilder(); temp.AppendFormat(" ...

  9. python-gitlab 统计代码行数

    需求:根据时间段,统计各个研发提交的代码行 实现逻辑:调用原生gitlab接口太复杂,引用python-gitlab 获取commit详情,然后进行统计 ======================= ...

  10. AutoFac实现程序集级别的依赖注入

    1.介绍      所谓程序集级别的依赖注入是指接口和实现的依赖不使用配置文件或硬代码实现(builder.RegisterType<UserInfoService>().As<IU ...