8000 Merge pull request #2 from Matthew-Cravinhos/master · kennyslater/javascript-exercises@cf1759d · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit cf1759d

Browse files
authored
Merge pull request TheOdinProject#2 from Matthew-Cravinhos/master
Fixed Directory Titles
2 parents f72bdd2 + 818c14e commit cf1759d

File tree

17 files changed

+452
-0
lines changed

17 files changed

+452
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

book_titles/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The goal of this exercise is to introduce you to the concept of objects and classes. These are fundamental building blocks for OOP (Object Oriented Programming). You shouldn't need to write a ton of new code, in fact you can re-use your solution from the Simon Says exercise!
2+
3+
The key here will be rewriting certain bits of it to work within the class given to you.

book_titles/bookTitles.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class bookTitle {
2+
3+
}
4+
5+
module.exports = {
6+
bookTitle
7+
}
8+

book_titles/bookTitles.spec.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
var bookTitles = require ('./bookTitles.js');
2+
3+
describe('bookTitle', function() {
4+
5+
var book; // note the scope here, if you declare this inside beforeEach then the scope won't allow it to access the other specs
6+
7+
beforeEach(function() {
8+
book = new bookTitles.bookTitle(); // creates a new book instance before each test is run
9+
});
10+
11+
describe('title', function() {
12+
13+
it('should capitalize the first letter', function() {
14+
book.title = 'inferno';
15+
expect(book.title).toEqual('Inferno');
16+
});
17+
18+
it('should capitalize every word', function() {
19+
book.title = 'stuart little';
20+
expect(book.title).toEqual('Stuart Little');
21+
});
22+
23+
describe('should capitalize every word except...', function() {
24+
describe('articles', function() {
25+
it('does not capitalize "the"', function() {
26+
book.title = 'alexander the great';
27+
expect(book.title).toEqual('Alexander the Great');
28+
});
29+
30+
it('does not capitalize "a"', function() {
31+
book.title = 'to kill a mockingbird';
32+
expect(book.title).toEqual('To Kill a Mockingbird');
33+
});
34+
35+
it('does not capitalize "an"', function() {
36+
book.title = 'to eat an apple a day';
37+
expect(book.title).toEqual('To Eat an Apple a Day');
38+
});
39+
});
40+
41+
it('conjunctions', function() {
42+
book.title = 'war and peace';
43+
expect(book.title).toEqual('War and Peace');
44+
});
45+
46+
it('prepositions', function() {
47+
book.title = 'love in the time of cholera';
48+
expect(book.title).toEqual('Love in the Time of Cholera');
49+
});
50+
});
51+
52+
describe('should always capitalize...', function() {
53+
it('I', function() {
54+
book.title = 'what i wish i knew when i was 20';
55+
expect(book.title).toEqual('What I Wish I Knew When I Was 20');
56+
});
57+
58+
it('the first word', function() {
59+
book.title = 'the man in the iron mask';
60+
expect(book.title).toEqual('The Man in the Iron Mask');
61+
});
62+
});
63+
});
64+
});

caesar/.DS_Store

6 KB
Binary file not shown.

calculator/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The goal for this exercise is to create a calculator that does the following:
2+
3+
add, subtract, get the sum, multiply, get the power, and find the factorial
4+
5+
In order to do this please fill out each function with your solution. Make sure to return the value so you can test it in Jasmine! To see the expected value
6+
take a look at the spec file that houses the Jasmine test cases.

calculator/calculator.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function add () {
2+
3+
}
4+
5+
function subtract () {
6+
7+
}
8+
9+
function sum () {
10+
11+
}
12+
13+
function multiply () {
14+
15+
}
16+
17+
function power() {
18+
19+
}
20+
21+
function factorial() {
22+
23+
}
24+
25+
module.exports = {
26+
add,
27+
subtract,
28+
sum,
29+
multiply,
30+
power,
31+
factorial
32+
}

calculator/calculator.spec.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
var calculator = require ('./calculator.js');
2+
3+
describe('add', function() {
4+
it('adds 0 and 0', function() {
5+
expect(calculator.add(0,0)).toEqual(0);
6+
});
7+
8+
it('adds 2 and 2', function() {
9+
expect(calculator.add(2,2)).toEqual(4);
10+
});
11+
12+
it('adds positive numbers', function() {
13+
expect(calculator.add(2,6)).toEqual(8);
14+
});
15+
});
16+
17+
describe('subtract', function() {
18+
it('subtracts numbers', function() {
19+
expect(calculator.subtract(10,4)).toEqual(6);
20+
});
21+
});
22+
23+
describe('sum', function() {
24+
it('computes the sum of an empty array', function() {
25+
expect(calculator.sum([])).toEqual(0);
26+
});
27+
28+
it('computes the sum of an array of one number', function() {
29+
expect(calculator.sum([7])).toEqual(7);
30+
});
31+
32+
it('computes the sum of an array of one number', function() {
33+
expect(calculator.sum([7,11])).toEqual(18);
34+
});
35+
36+
it('computes the sum of an array of many numbers', function() {
37+
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
38+
});
39+
});
40+
41+
describe('multiply', function() {
42+
it('multiplies two numbers', function() {
43+
expect(calculator.multiply([2,4])).toEqual(8);
44+
});
45+
46+
it('multiplies several numbers', function() {
47+
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
48+
});
49+
});
50+
51+
describe('power', function() {
52+
it('raises one number to the power of another number', function() {
53+
expect(calculator.power(4,3)).toEqual(64); // 4 to third power is 64
54+
});
55+
});
56+
57+
describe('factorial', function() {
58+
it('computes the factorial of 0', function() {
59+
expect(calculator.factorial(0)).toEqual(0);
60+
});
61+
62+
it('computes the factorial of 1', function() {
63+
expect(calculator.factorial(1)).toEqual(1);
64+
});
65+
66+
it('computes the factorial of 2', function() {
67+
expect(calculator.factorial(2)).toEqual(2);
68+
});
69+
70+
it('computes the factorial of 5', function() {
71+
expect(calculator.factorial(5)).toEqual(120);
72+
});
73+
74+
it('computes the factorial of 10', function() {
75+
expect(calculator.factorial(10)).toEqual(3628800);
76+
});
77+
});

pig_latin/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pig Latin is a children's language that is intended to be confusing when spoken quickly. Your job for this exercise is to create a solution that takes the words given and
2+
turns them into pig latin. Please see the following wikipedia page for details regarding the rules of Pig Latin:
3+
4+
https://en.wikipedia.org/wiki/Pig_Latin
5+
6+
The rules section will give the rules and the examples that are required to complete this exercise.

pig_latin/pigLatin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function translate() {
2+
// body...
3+
}
4+
5+
6+
module.exports = {
7+
translate
8+
}
9+

0 commit comments

Comments
 (0)
0