[Algorithm] Find The Vowels
// --- 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的更多相关文章
- Java Algorithm Problems
Java Algorithm Problems 程序员的一天 从开始这个Github已经有将近两年时间, 很高兴这个repo可以帮到有需要的人. 我一直认为, 知识本身是无价的, 因此每逢闲暇, 我就 ...
- 挑子学习笔记:两步聚类算法(TwoStep Cluster Algorithm)——改进的BIRCH算法
转载请标明出处:http://www.cnblogs.com/tiaozistudy/p/twostep_cluster_algorithm.html 两步聚类算法是在SPSS Modeler中使用的 ...
- PE Checksum Algorithm的较简实现
这篇BLOG是我很早以前写的,因为现在搬移到CNBLOGS了,经过整理后重新发出来. 工作之前的几年一直都在搞计算机安全/病毒相关的东西(纯学习,不作恶),其中PE文件格式是必须知识.有些PE文件,比 ...
- [异常解决] windows用SSH和linux同步文件&linux开启SSH&ssh client 报 algorithm negotiation failed的解决方法之一
1.安装.配置与启动 SSH分客户端openssh-client和openssh-server 如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有 ...
- [Algorithm] 使用SimHash进行海量文本去重
在之前的两篇博文分别介绍了常用的hash方法([Data Structure & Algorithm] Hash那点事儿)以及局部敏感hash算法([Algorithm] 局部敏感哈希算法(L ...
- Backtracking algorithm: rat in maze
Sept. 10, 2015 Study again the back tracking algorithm using recursive solution, rat in maze, a clas ...
- [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 ...
- [Algorithm & NLP] 文本深度表示模型——word2vec&doc2vec词向量模型
深度学习掀开了机器学习的新篇章,目前深度学习应用于图像和语音已经产生了突破性的研究进展.深度学习一直被人们推崇为一种类似于人脑结构的人工智能算法,那为什么深度学习在语义分析领域仍然没有实质性的进展呢? ...
- [Algorithm] 群体智能优化算法之粒子群优化算法
同进化算法(见博客<[Evolutionary Algorithm] 进化算法简介>,进化算法是受生物进化机制启发而产生的一系列算法)和人工神经网络算法(Neural Networks,简 ...
随机推荐
- PTA(Advanced Level)1037.Magic Coupon
The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, m ...
- 正确理解使用Vue里的nextTick方法
最近,在项目中要使用Swiper做一个移动端轮播插件.需要先异步动态加载数据后,然后使用v-for渲染节点,再执行插件的滑动轮播行为.解决这个问题,我们通过在组件中使用vm.$nextTick来解决这 ...
- AMD全新32核线程撕裂者GeekBench跑分曝光:超2950X近一倍
AMD全新32核线程撕裂者GeekBench跑分曝光:超2950X近一倍 2019年09月01日 09:36 1109 次阅读 稿源:快科技 1 条评论 https://www.cnbeta.com/ ...
- [转载]ASP.NET Core文件上传与下载(多种上传方式)
ASP.NET Core文件上传与下载(多种上传方式) 前言 前段时间项目上线,实在太忙,最近终于开始可以研究研究ASP.NET Core了. 打算写个系列,但是还没想好目录,今天先来一篇,后面在 ...
- 使用mybatis出现异常:invalid comparison: java.time.LocalDateTime and java.lang.String
整了半天终于找到问题所在:在mapper文件中,对该参数进行了和字符串的对比,如下: <if test="startTime != null and startTime != '' a ...
- javaweb项目的全局监听配置
在项目中有时候会遇到全局监听的需求,而全局性的监听该如何配置,代码如下: package com.demo.listener; import javax.servlet.ServletContextE ...
- ubuntu下安装navicat
1.去官网下载 https://www.navicat.com/en/download/navicat-premium 2.命令行输入(解压命令) tar -zxvf xxxxx.tar.gz 3.移 ...
- Codeforces 718A Efim and Strange Grade 程序分析
Codeforces 718A Efim and Strange Grade 程序分析 jerry的程序 using namespace std; typedef long long ll; stri ...
- Jmeter4.0---- jmeter逻辑控制器(16)
1.说明 逻辑控制器可以帮助用户控制Jmeter的测试逻辑,特别是何时发送请求.逻辑控制器可以改变其子测试元件的请求执行顺序. 2.逻辑控制器 (1)如果(if)控制器 用法一: 审核人员,数据分为 ...
- VS 之github
VS 代码发布到TFS上 1. 登录 visualstudio.com. 进入 https://qgb.visualstudio.com Create Project 这里是相当于新建了一个文件夹 ...