Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions book_titles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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!

The key here will be rewriting certain bits of it to work within the class given to you.
8 changes: 8 additions & 0 deletions book_titles/bookTitles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class bookTitle {

}

module.exports = {
bookTitle
}

64 changes: 64 additions & 0 deletions book_titles/bookTitles.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
var bookTitles = require ('./bookTitles.js');

describe('bookTitle', function() {

var book; // note the scope here, if you declare this inside beforeEach then the scope won't allow it to access the other specs

beforeEach(function() {
book = new bookTitles.bookTitle(); // creates a new book instance before each test is run
});

describe('title', function() {

it('should capitalize the first letter', function() {
book.title = 'inferno';
expect(book.title).toEqual('Inferno');
});

it('should capitalize every word', function() {
book.title = 'stuart little';
expect(book.title).toEqual('Stuart Little');
});

describe('should capitalize every word except...', function() {
describe('articles', function() {
it('does not capitalize "the"', function() {
book.title = 'alexander the great';
expect(book.title).toEqual('Alexander the Great');
});

it('does not capitalize "a"', function() {
book.title = 'to kill a mockingbird';
expect(book.title).toEqual('To Kill a Mockingbird');
});

it('does not capitalize "an"', function() {
book.title = 'to eat an apple a day';
expect(book.title).toEqual('To Eat an Apple a Day');
});
});

it('conjunctions', function() {
book.title = 'war and peace';
expect(book.title).toEqual('War and Peace');
});

it('prepositions', function() {
book.title = 'love in the time of cholera';
expect(book.title).toEqual('Love in the Time of Cholera');
});
});

describe('should always capitalize...', function() {
it('I', function() {
book.title = 'what i wish i knew when i was 20';
expect(book.title).toEqual('What I Wish I Knew When I Was 20');
});

it('the first word', function() {
book.title = 'the man in the iron mask';
expect(book.title).toEqual('The Man in the Iron Mask');
});
});
});
});
Binary file added caesar/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The goal for this exercise is to create a calculator that does the following:

add, subtract, get the sum, multiply, get the power, and find the factorial

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
take a look at the spec file that houses the Jasmine test cases.
32 changes: 32 additions & 0 deletions calculator/calculator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function add () {

}

function subtract () {

}

function sum () {

}

function multiply () {

}

function power() {

}

function factorial() {

}

module.exports = {
add,
subtract,
sum,
multiply,
power,
factorial
}
77 changes: 77 additions & 0 deletions calculator/calculator.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
var calculator = require ('./calculator.js');

describe('add', function() {
it('adds 0 and 0', function() {
expect(calculator.add(0,0)).toEqual(0);
});

it('adds 2 and 2', function() {
expect(calculator.add(2,2)).toEqual(4);
});

it('adds positive numbers', function() {
expect(calculator.add(2,6)).toEqual(8);
});
});

describe('subtract', function() {
it('subtracts numbers', function() {
expect(calculator.subtract(10,4)).toEqual(6);
});
});

describe('sum', function() {
it('computes the sum of an empty array', function() {
expect(calculator.sum([])).toEqual(0);
});

it('computes the sum of an array of one number', function() {
expect(calculator.sum([7])).toEqual(7);
});

it('computes the sum of an array of one number', function() {
expect(calculator.sum([7,11])).toEqual(18);
});

it('computes the sum of an array of many numbers', function() {
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
});
});

describe('multiply', function() {
it('multiplies two numbers', function() {
expect(calculator.multiply([2,4])).toEqual(8);
});

it('multiplies several numbers', function() {
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
});
});

describe('power', function() {
it('raises one number to the power of another number', function() {
expect(calculator.power(4,3)).toEqual(64); // 4 to third power is 64
});
});

describe('factorial', function() {
it('computes the factorial of 0', function() {
expect(calculator.factorial(0)).toEqual(0);
});

it('computes the factorial of 1', function() {
expect(calculator.factorial(1)).toEqual(1);
});

it('computes the factorial of 2', function() {
expect(calculator.factorial(2)).toEqual(2);
});

it('computes the factorial of 5', function() {
expect(calculator.factorial(5)).toEqual(120);
});

it('computes the factorial of 10', function() {
expect(calculator.factorial(10)).toEqual(3628800);
});
});
6 changes: 6 additions & 0 deletions pig_latin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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
turns them into pig latin. Please see the following wikipedia page for details regarding the rules of Pig Latin:

https://en.wikipedia.org/wiki/Pig_Latin

The rules section will give the rules and the examples that are required to complete this exercise.
9 changes: 9 additions & 0 deletions pig_latin/pigLatin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function translate() {
// body...
}


module.exports = {
translate
}

64 changes: 64 additions & 0 deletions pig_latin/pigLatin.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Topics

// * modules
// * strings

// Pig Latin

// Pig Latin is a made-up children's language that's intended to be confusing. It obeys a few simple rules (below) but when it's spoken quickly it's really difficult for non-children (and non-native speakers) to understand.

// Rule 1: If a word begins with a vowel sound, add an "ay" sound to the end of the word.

// Rule 2: If a word begins with a consonant sound, move it to the end of the word, and then add an "ay" sound to the end of the word.

// (There are a few more rules for edge cases, and there are regional variants too, but that should be enough to understand the tests.)

// See https://en.wikipedia.org/wiki/Pig_Latin for more details.

var pigLatin = require("./pigLatin.js");

describe('#translate', function() {
it('translates a word beginning with a vowel', function() {
s = pigLatin.translate("apple");
expect(s).toEqual('appleay');
});

it('translates a word beginning with a consonant', function() {
s = pigLatin.translate("banana");
expect(s).toEqual("ananabay");
});

it('translates a word beginning with two consonants', function() {
s = pigLatin.translate("cherry");
expect(s).toEqual('errychay');
});

it('translates two words', function() {
s = pigLatin.translate("eat pie");
expect(s).toEqual('eatay iepay');
});

it('translates a word beginning with three consonants', function() {
expect(pigLatin.translate("three")).toEqual("eethray");
});

it('counts "sch" as a single phoneme', function() {
s = pigLatin.translate("school");
expect(s).toEqual("oolschay");
});

it('counts "qu" as a single phoneme', function() {
s = pigLatin.translate("quiet");
expect(s).toEqual("ietquay");
});

it('counts "qu" as a consonant even when its preceded by a consonant', function() {
s = pigLatin.translate("square");
expect(s).toEqual("aresquay");
});

it('translates many words', function() {
s = pigLatin.translate("the quick brown fox");
expect(s).toEqual("ethay ickquay ownbray oxfay");
});
});
15 changes: 15 additions & 0 deletions simon_says/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This exercise is meant to (loosely) simulate the game Simon Says. The goal of this program in order is:

Echo the value given,

Capitalize the value given,

Repeat the value given,

Return a piece of the value given,

Return the first word of the value given,

Create a title with the value given

See Jasmine test cases for expected results.
37 changes: 37 additions & 0 deletions simon_says/simonSays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function echo() {

}

function shout() {

}

function repeat() {

}

function pieceOfWord() {

}

function firstWord() {

}

function capitalize(word) {
return word.charAt(0).toUpperCase() + word.slice(1);
// This function just capitalizes the word given to it, use in conjunction with titleCreator
}

function titleCreator() {

}

module.exports = {
echo,
shout,
repeat,
pieceOfWord,
firstWord,
titleCreator
}
Loading