Remove removeVowels
This commit is contained in:
@ -1,18 +0,0 @@
|
||||
---
|
||||
title: removeVowels
|
||||
tags: string,beginner
|
||||
---
|
||||
|
||||
Returns all the vowels in a `str` replaced by `repl`.
|
||||
|
||||
Use `String.prototype.replace()` with a regexp to replace all vowels in `str`.
|
||||
Omot `repl` to use a default value of `''`.
|
||||
|
||||
```js
|
||||
const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi, repl);
|
||||
```
|
||||
|
||||
```js
|
||||
removeVowels("foobAr"); // "fbr"
|
||||
removeVowels("foobAr","*"); // "f**b*r"
|
||||
```
|
||||
@ -1,11 +0,0 @@
|
||||
const {removeVowels} = require('./_30s.js');
|
||||
|
||||
test('removeVowels is a Function', () => {
|
||||
expect(removeVowels).toBeInstanceOf(Function);
|
||||
});
|
||||
test('Removes vowels.', () => {
|
||||
expect(removeVowels('foobAr')).toBe('fbr');
|
||||
});
|
||||
test('Replaces vowels.', () => {
|
||||
expect(removeVowels('foobAr', '*')).toBe('f**b*r');
|
||||
});
|
||||
Reference in New Issue
Block a user