[Algorithm] Find The Vowels
生活随笔
收集整理的這篇文章主要介紹了
[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); });
?
轉載于:https://www.cnblogs.com/Answer1215/p/11067274.html
總結
以上是生活随笔為你收集整理的[Algorithm] Find The Vowels的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql interval 3 day
- 下一篇: 视频剪辑软件调研