-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import vowelOne from '.'; | ||
|
||
describe('vowelOne', () => { | ||
it('should replace vowels with `1` and non-vowels with `0`', () => { | ||
expect(vowelOne('vowelOne')).toEqual('01010101'); | ||
expect(vowelOne('123, arou')).toEqual('000001011'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function vowelOne(s: string): string { | ||
return s.replace(/([aeiou])|./gi, (_, vowel) => { | ||
return vowel ? '1' : '0'; | ||
}); | ||
} | ||
|
||
export default vowelOne; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# [Vowel one](https://www.codewars.com/kata/580751a40b5a777a200000a1) | ||
|
||
### vowelOne | ||
|
||
Write a function that takes a string and outputs a strings of 1's and 0's where vowels become 1's and non-vowels become 0's. | ||
|
||
All non-vowels including non alpha characters (spaces,commas etc.) should be included. | ||
|
||
Examples: | ||
|
||
```haskell | ||
vowelOne "abceios" -- "1001110" | ||
|
||
vowelOne "aeiou, abc" -- "1111100100" | ||
``` | ||
|
||
```javascript | ||
vowelOne('abceios'); // "1001110" | ||
|
||
vowelOne('aeiou, abc'); // "1111100100" | ||
``` | ||
|
||
--- | ||
|
||
## Tags | ||
|
||
- Fundamentals | ||
- Strings |