add snakeCase

This commit is contained in:
Cody Loyd 2017-08-25 14:16:42 -05:00
parent f04a440e58
commit 4dc777616c
4 changed files with 38 additions and 2 deletions

View file

@ -13,8 +13,6 @@ The first exercise, `helloWorld` will walk you through the process in more depth
## planned exercises (in no particular order for the moment):
1. book titles (MC)
1. Palindromes
1. Pangrams
1. pig latin (MC)
1. fibonacci
1. convert to snake case

10
snakeCase/README.md Normal file
View file

@ -0,0 +1,10 @@
# Exercise XX - snakeCase
Convert phrases and words into snake case
> Snake case (or snake\_case) is the practice of writing compound words or phrases in which the elements are separated with one underscore character (\_) and no spaces, with each element's initial letter usually lowercased as in "foo\_bar"
```javascript
snakeCase('Hello, World!') // hello_world
snakeCase('snakeCase') // snake_case
```

5
snakeCase/snakeCase.js Normal file
View file

@ -0,0 +1,5 @@
var snakeCase = function() {
}
module.exports = snakeCase

View file

@ -0,0 +1,23 @@
var snakeCase = require('./snakeCase')
describe('snakeCase', function() {
it('works with simple lowercased phrases', function() {
expect(snakeCase('hello world')).toEqual('hello_world');
});
xit('works with Caps and punctuation', function() {
expect(snakeCase('Hello, World???')).toEqual('hello_world');
});
xit('works with longer phrases', function() {
expect(snakeCase('This is the song that never ends....')).toEqual('this_is_the_song_that_never_ends');
});
xit('works with camel case', function() {
expect(snakeCase('snakeCase')).toEqual('snake_case');
});
xit('works with kebab case', function() {
expect(snakeCase('snake-case')).toEqual('snake_case');
});
xit('works with WTF case', function() {
expect(snakeCase('SnAkE..CaSe..Is..AwEsOmE')).toEqual('snake_case_is_awesome');
});
});