Revert "Resolve merge conflicts"
This reverts commit61338e0ca0
, reversing changes made tob9983073cc
.
This commit is contained in:
parent
18cffeb940
commit
b2f2211321
|
@ -1 +1,2 @@
|
||||||
.vscode
|
.vscode
|
||||||
|
node_modules
|
||||||
|
|
|
@ -9,12 +9,10 @@ There will eventually be a suggested order of completion, but at this time since
|
||||||
## How To Use These Exercises
|
## How To Use These Exercises
|
||||||
Before you start you should have a few things installed on your machine:
|
Before you start you should have a few things installed on your machine:
|
||||||
1. NPM. To check if you have NPM installed, type `npm --version` in your terminal. If you get back `Command 'npm' not found, but can be installed with:`, do NOT follow the instructions in the terminal to install with `apt-get`. (This causes permission issues.) Instead, install Node with NVM by following the instructions [here](https://github.com/TheOdinProject/curriculum/blob/master/foundations/installations/installing_node.md).
|
1. NPM. To check if you have NPM installed, type `npm --version` in your terminal. If you get back `Command 'npm' not found, but can be installed with:`, do NOT follow the instructions in the terminal to install with `apt-get`. (This causes permission issues.) Instead, install Node with NVM by following the instructions [here](https://github.com/TheOdinProject/curriculum/blob/master/foundations/installations/installing_node.md).
|
||||||
2. Jest. Jest is a testing framework for JavaScript. To install it, type `npm install --save-dev jest`. We use `--save-dev` here to specify this module is for development purposes only.
|
2. Jasmine. Jasmine is a testing framework for JavaScript. Type `jasmine -v` to check for it. If you need to install it, type `npm install -g jasmine` to do so.
|
||||||
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository).
|
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
|
||||||
|
|
||||||
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `npm test exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'test.skip' compared to 'test'. This is purposeful. After you pass your first 'test', you will change the next 'test.skip' to an 'test' and test your code again. You'll do this until all conditions are satisfied.
|
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `jasmine exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'xit' compared to 'it'. This is purposeful. After you pass your first 'it', you will change the next 'xit' to an 'it' and test your code again. You'll do this until all conditions are satisfied.
|
||||||
|
|
||||||
**Note**: Due to the way Jest handles failed tests, it will return an exit code of 1 if any tests fail. NPM will interpret this as an error and you may see some `npm ERR!` messages after Jest runs. You can ignore these, or run your test with `npm test exerciseName.spec.js --silent` to supress the errors.
|
|
||||||
|
|
||||||
The first exercise, `helloWorld`, will walk you through the process in-depth.
|
The first exercise, `helloWorld`, will walk you through the process in-depth.
|
||||||
|
|
||||||
|
|
|
@ -1,77 +1,77 @@
|
||||||
const calculator = require ('./calculator.js');
|
const calculator = require ('./calculator.js');
|
||||||
|
|
||||||
describe('add', () => {
|
describe('add', function() {
|
||||||
test('adds 0 and 0', () => {
|
it('adds 0 and 0', function() {
|
||||||
expect(calculator.add(0,0)).toBe(0);
|
expect(calculator.add(0,0)).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('adds 2 and 2', () => {
|
xit('adds 2 and 2', function() {
|
||||||
expect(calculator.add(2,2)).toBe(4);
|
expect(calculator.add(2,2)).toEqual(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('adds positive numbers', () => {
|
xit('adds positive numbers', function() {
|
||||||
expect(calculator.add(2,6)).toBe(8);
|
expect(calculator.add(2,6)).toEqual(8);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('subtract', () => {
|
describe('subtract', function() {
|
||||||
test('subtracts numbers', () => {
|
xit('subtracts numbers', function() {
|
||||||
expect(calculator.subtract(10,4)).toBe(6);
|
expect(calculator.subtract(10,4)).toEqual(6);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('sum', () => {
|
describe('sum', function() {
|
||||||
test('computes the sum of an empty array', () => {
|
xit('computes the sum of an empty array', function() {
|
||||||
expect(calculator.sum([])).toBe(0);
|
expect(calculator.sum([])).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('computes the sum of an array of one number', () => {
|
xit('computes the sum of an array of one number', function() {
|
||||||
expect(calculator.sum([7])).toBe(7);
|
expect(calculator.sum([7])).toEqual(7);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('computes the sum of an array of two numbers', () => {
|
xit('computes the sum of an array of two numbers', function() {
|
||||||
expect(calculator.sum([7,11])).toBe(18);
|
expect(calculator.sum([7,11])).toEqual(18);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('computes the sum of an array of many numbers', () => {
|
xit('computes the sum of an array of many numbers', function() {
|
||||||
expect(calculator.sum([1,3,5,7,9])).toBe(25);
|
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('multiply', () => {
|
describe('multiply', function() {
|
||||||
test('multiplies two numbers', () => {
|
xit('multiplies two numbers', function() {
|
||||||
expect(calculator.multiply([2,4])).toBe(8);
|
expect(calculator.multiply([2,4])).toEqual(8);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('multiplies several numbers', () => {
|
xit('multiplies several numbers', function() {
|
||||||
expect(calculator.multiply([2,4,6,8,10,12,14])).toBe(645120);
|
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('power', () => {
|
describe('power', function() {
|
||||||
test('raises one number to the power of another number', () => {
|
xit('raises one number to the power of another number', function() {
|
||||||
expect(calculator.power(4,3)).toBe(64); // 4 to third power is 64
|
expect(calculator.power(4,3)).toEqual(64); // 4 to third power is 64
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('factorial', () => {
|
describe('factorial', function() {
|
||||||
test.skip('computes the factorial of 0', () => {
|
xit('computes the factorial of 0', function() {
|
||||||
expect(calculator.factorial(0)).toBe(1); // 0! = 1
|
expect(calculator.factorial(0)).toEqual(1); // 0! = 1
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('computes the factorial of 1', () => {
|
xit('computes the factorial of 1', function() {
|
||||||
expect(calculator.factorial(1)).toBe(1);
|
expect(calculator.factorial(1)).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('computes the factorial of 2', () => {
|
xit('computes the factorial of 2', function() {
|
||||||
expect(calculator.factorial(2)).toBe(2);
|
expect(calculator.factorial(2)).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('computes the factorial of 5', () => {
|
xit('computes the factorial of 5', function() {
|
||||||
expect(calculator.factorial(5)).toBe(120);
|
expect(calculator.factorial(5)).toEqual(120);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('computes the factorial of 10', () => {
|
xit('computes the factorial of 10', function() {
|
||||||
expect(calculator.factorial(10)).toBe(3628800);
|
expect(calculator.factorial(10)).toEqual(3628800);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
const fibonacci = function () {};
|
const fibonacci = function () {};
|
||||||
|
|
||||||
module.exports = fibonacci;
|
module.exports = fibonacci
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
let findTheOldest = function () {};
|
let findTheOldest = function () {};
|
||||||
|
|
||||||
module.exports = findTheOldest;
|
module.exports = findTheOldest;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const findTheOldest = require("./findTheOldest");
|
let findTheOldest = require("./findTheOldest");
|
||||||
|
|
||||||
describe("findTheOldest", () => {
|
describe("findTheOldest", function () {
|
||||||
test("finds the oldest person!", () => {
|
it("finds the oldest person!", function () {
|
||||||
const people = [
|
const people = [
|
||||||
{
|
{
|
||||||
name: "Carly",
|
name: "Carly",
|
||||||
|
@ -19,7 +19,7 @@ describe("findTheOldest", () => {
|
||||||
yearOfDeath: 1941,
|
yearOfDeath: 1941,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
expect(findTheOldest(people).name).toBe("Ray");
|
expect(findTheOldest(people).name).toEqual("Ray");
|
||||||
});
|
});
|
||||||
xit("finds the oldest person if someone is still living", function () {
|
xit("finds the oldest person if someone is still living", function () {
|
||||||
const people = [
|
const people = [
|
||||||
|
@ -38,7 +38,7 @@ describe("findTheOldest", () => {
|
||||||
yearOfDeath: 1941,
|
yearOfDeath: 1941,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
expect(findTheOldest(people).name).toBe("Ray");
|
expect(findTheOldest(people).name).toEqual("Ray");
|
||||||
});
|
});
|
||||||
xit("finds the oldest person if the OLDEST is still living", function () {
|
xit("finds the oldest person if the OLDEST is still living", function () {
|
||||||
const people = [
|
const people = [
|
||||||
|
@ -57,6 +57,6 @@ describe("findTheOldest", () => {
|
||||||
yearOfDeath: 1941,
|
yearOfDeath: 1941,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
expect(findTheOldest(people).name).toBe("Carly");
|
expect(findTheOldest(people).name).toEqual("Carly");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const getTheTitles = require("./getTheTitles");
|
let getTheTitles = require("./getTheTitles");
|
||||||
|
|
||||||
describe("getTheTitles", function () {
|
describe("getTheTitles", function () {
|
||||||
const books = [
|
const books = [
|
||||||
|
@ -12,7 +12,7 @@ describe("getTheTitles", function () {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
test("gets titles", () => {
|
it("gets titles", function () {
|
||||||
expect(getTheTitles(books)).toBe(["Book", "Book2"]);
|
expect(getTheTitles(books)).toEqual(["Book", "Book2"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,4 +2,4 @@ const helloWorld = function() {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = helloWorld;
|
module.exports = helloWorld
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
const helloWorld = require('./helloWorld');
|
const helloWorld = require('./helloWorld');
|
||||||
|
|
||||||
test('says "Hello, World!"', function() {
|
describe('Hello World', function() {
|
||||||
expect(helloWorld()).toBe("Hello, World!");
|
it('says hello world', function() {
|
||||||
|
expect(helloWorld()).toEqual('Hello, World!');
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -1,8 +1,8 @@
|
||||||
const leapYears = require("./leapYears");
|
const leapYears = require("./leapYears");
|
||||||
|
|
||||||
describe("leapYears", () => {
|
describe("leapYears", function () {
|
||||||
test("works with non century years", () => {
|
it("works with non century years", function () {
|
||||||
expect(leapYears(1996)).toBe(true);
|
expect(leapYears(1996)).toEqual(true);
|
||||||
});
|
});
|
||||||
xit("works with non century years", function () {
|
xit("works with non century years", function () {
|
||||||
expect(leapYears(1997)).toEqual(false);
|
expect(leapYears(1997)).toEqual(false);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"devDependencies": {
|
|
||||||
"jest": "^26.6.3",
|
|
||||||
"jest-cli": "^26.6.3"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "jest"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +1,3 @@
|
||||||
const palindromes = function () {};
|
const palindromes = function () {};
|
||||||
|
|
||||||
module.exports = palindromes;
|
module.exports = palindromes
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const expect = require("expect");
|
|
||||||
|
|
||||||
// Topics
|
// Topics
|
||||||
|
|
||||||
// * modules
|
// * modules
|
||||||
|
@ -7,11 +5,11 @@ const expect = require("expect");
|
||||||
|
|
||||||
// Pig Latin
|
// Pig Latin
|
||||||
|
|
||||||
// Pig Latin is a made-up children's language that's intended to be confusing. test obeys a few simple rules (below) but when test's spoken quickly test's really difficult for non-children (and non-native speakers) to understand.
|
// 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 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 test to the end of the word, and then 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.)
|
// (There are a few more rules for edge cases, and there are regional variants too, but that should be enough to understand the tests.)
|
||||||
|
|
||||||
|
@ -19,48 +17,48 @@ const expect = require("expect");
|
||||||
|
|
||||||
const pigLatin = require("./pigLatin.js");
|
const pigLatin = require("./pigLatin.js");
|
||||||
|
|
||||||
describe('translate', () => {
|
describe('#translate', function() {
|
||||||
test('translates a word beginning with a vowel', () => {
|
it('translates a word beginning with a vowel', function() {
|
||||||
s = pigLatin.translate("apple");
|
s = pigLatin.translate("apple");
|
||||||
expect(s).toBe('appleay');
|
expect(s).toEqual('appleay');
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('translates a word beginning with a consonant', () => {
|
xit('translates a word beginning with a consonant', function() {
|
||||||
s = pigLatin.translate("banana");
|
s = pigLatin.translate("banana");
|
||||||
expect(s).toBe("ananabay");
|
expect(s).toEqual("ananabay");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('translates a word beginning with two consonants', () => {
|
xit('translates a word beginning with two consonants', function() {
|
||||||
s = pigLatin.translate("cherry");
|
s = pigLatin.translate("cherry");
|
||||||
expect(s).toBe('errychay');
|
expect(s).toEqual('errychay');
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('translates two words', () => {
|
xit('translates two words', function() {
|
||||||
s = pigLatin.translate("eat pie");
|
s = pigLatin.translate("eat pie");
|
||||||
expect(s).toBe('eatay iepay');
|
expect(s).toEqual('eatay iepay');
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('translates a word beginning with three consonants', () => {
|
xit('translates a word beginning with three consonants', function() {
|
||||||
expect(pigLatin.translate("three")).toBe("eethray");
|
expect(pigLatin.translate("three")).toEqual("eethray");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('counts "sch" as a single phoneme', () => {
|
xit('counts "sch" as a single phoneme', function() {
|
||||||
s = pigLatin.translate("school");
|
s = pigLatin.translate("school");
|
||||||
expect(s).toBe("oolschay");
|
expect(s).toEqual("oolschay");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('counts "qu" as a single phoneme', () => {
|
xit('counts "qu" as a single phoneme', function() {
|
||||||
s = pigLatin.translate("quiet");
|
s = pigLatin.translate("quiet");
|
||||||
expect(s).toBe("ietquay");
|
expect(s).toEqual("ietquay");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('counts "qu" as a consonant even when its preceded by a consonant', () => {
|
xit('counts "qu" as a consonant even when its preceded by a consonant', function() {
|
||||||
s = pigLatin.translate("square");
|
s = pigLatin.translate("square");
|
||||||
expect(s).toBe("aresquay");
|
expect(s).toEqual("aresquay");
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('translates many words', () => {
|
xit('translates many words', function() {
|
||||||
s = pigLatin.translate("the quick brown fox");
|
s = pigLatin.translate("the quick brown fox");
|
||||||
expect(s).toBe("ethay ickquay ownbray oxfay");
|
expect(s).toEqual("ethay ickquay ownbray oxfay");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const removeFromArray = require("./removeFromArray");
|
const removeFromArray = require("./removeFromArray");
|
||||||
|
|
||||||
describe("removeFromArray", () => {
|
describe("removeFromArray", function () {
|
||||||
test("removes a single value", () => {
|
it("removes a single value", function () {
|
||||||
expect(removeFromArray([1, 2, 3, 4], 3)).toBe([1, 2, 4]);
|
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
|
||||||
});
|
});
|
||||||
xit("removes multiple values", function () {
|
xit("removes multiple values", function () {
|
||||||
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
|
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
|
||||||
|
@ -19,7 +19,7 @@ describe("removeFromArray", () => {
|
||||||
xit("works with strings", function () {
|
xit("works with strings", function () {
|
||||||
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
|
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
|
||||||
});
|
});
|
||||||
test.skip("only removes same type", () => {
|
xit("only removes same type", function () {
|
||||||
expect(removeFromArray([1, 2, 3], "1", 3)).toBe([1, 2]);
|
expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const expect = require('expect');const repeatString = require('./repeatString')
|
const repeatString = require('./repeatString')
|
||||||
|
|
||||||
describe('repeatString', function() {
|
describe('repeatString', function() {
|
||||||
it('repeats the string', function() {
|
it('repeats the string', function() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const expect = require('expect');const reverseString = require('./reverseString')
|
const reverseString = require('./reverseString')
|
||||||
|
|
||||||
describe('reverseString', function() {
|
describe('reverseString', function() {
|
||||||
it('reverses single word', function() {
|
it('reverses single word', function() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const expect = require('expect');const {ftoc, ctof} = require('./tempConversion')
|
const {ftoc, ctof} = require('./tempConversion')
|
||||||
|
|
||||||
describe('ftoc', function() {
|
describe('ftoc', function() {
|
||||||
it('works', function() {
|
it('works', function() {
|
||||||
|
|
Loading…
Reference in New Issue