Skip to content

Commit 4dc7776

Browse files
committed
add snakeCase
1 parent f04a440 commit 4dc7776

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ The first exercise, `helloWorld` will walk you through the process in more depth
1313

1414
## planned exercises (in no particular order for the moment):
1515
1. book titles (MC)
16-
1. Palindromes
17-
1. Pangrams
1816
1. pig latin (MC)
1917
1. fibonacci
2018
1. convert to snake case

snakeCase/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Exercise XX - snakeCase
2+
3+
Convert phrases and words into snake case
4+
5+
> 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"
6+
7+
```javascript
8+
snakeCase('Hello, World!') // hello_world
9+
snakeCase('snakeCase') // snake_case
10+
```

snakeCase/snakeCase.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var snakeCase = function() {
2+
3+
}
4+
5+
module.exports = snakeCase

snakeCase/snakeCase.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var snakeCase = require('./snakeCase')
2+
3+
describe('snakeCase', function() {
4+
it('works with simple lowercased phrases', function() {
5+
expect(snakeCase('hello world')).toEqual('hello_world');
6+
});
7+
xit('works with Caps and punctuation', function() {
8+
expect(snakeCase('Hello, World???')).toEqual('hello_world');
9+
});
10+
xit('works with longer phrases', function() {
11+
expect(snakeCase('This is the song that never ends....')).toEqual('this_is_the_song_that_never_ends');
12+
});
13+
xit('works with camel case', function() {
14+
expect(snakeCase('snakeCase')).toEqual('snake_case');
15+
});
16+
xit('works with kebab case', function() {
17+
expect(snakeCase('snake-case')).toEqual('snake_case');
18+
});
19+
xit('works with WTF case', function() {
20+
expect(snakeCase('SnAkE..CaSe..Is..AwEsOmE')).toEqual('snake_case_is_awesome');
21+
});
22+
23+
});

0 commit comments

Comments
 (0)