8000 Revert "Merge branch 'jest'" · jinc1026/javascript-exercises@ad1c0c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit ad1c0c4

Browse files
committed
Revert "Merge branch 'jest'"
This reverts commit f76e9e1.
1 parent f76e9e1 commit ad1c0c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+216
-6165
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
.vscode
2-
node_modules/
3-
.DS_Store
1+
.vscode

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Before you start you should have a few things installed on your machine:
1414

1515
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.
1616

17-
**Note**: Due to the way Jest handles failed tests, it may 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.
18-
1917
The first exercise, `helloWorld`, will walk you through the process in-depth.
2018

2119
## Solutions

caesar/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Exercise 13 - Caesar cipher
1+
# Exercise XX - caesar cipher
22

3-
Implement the legendary Caesar cipher:
3+
Implement the legendary caesar cipher:
44

55
> In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.
66
@@ -31,3 +31,5 @@ negative numbers should work as well:
3131
```javascript
3232
caesar('Mjqqt, Btwqi!', -5) // returns 'Hello, World!'
3333
```
34+
35+

caesar/caesar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const caesar = function() {
22

3-
};
3+
}
44

5-
module.exports = caesar;
5+
module.exports = caesar

calculator/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# Exercise 08 - Calculator
2-
31
The goal for this exercise is to create a calculator that does the following:
42

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

7-
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 Jest! To see the expected value
8-
take a look at the spec file that houses the Jest test cases.
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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
const add = function() {
1+
function add () {
22

3-
};
3+
}
44

5-
const subtract = function() {
5+
function subtract () {
66

7-
};
7+
}
88

9-
const sum = function() {
9+
function sum () {
1010

11-
};
12-
13-
const multiply = function() {
11+
}
1412

15-
};;
13+
function multiply () {
14+
15+
}
1616

17-
const power = function() {
17+
function power() {
1818

19-
};
19+
}
2020

21-
const factorial = function() {
21+
function factorial() {
2222

23-
};
23+
}
2424

2525
module.exports = {
2626
add,
2727
subtract,
2828
sum,
2929
multiply,
3030
power,
31-
factorial
31+
factorial,
3232
};

calculator/calculator.spec.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
const calculator = require('./calculator');
1+
const calculator = require ('./calculator.js');
22

33
describe('add', function() {
44
it('adds 0 and 0', function() {
55
expect(calculator.add(0,0)).toEqual(0);
66
});
77

8-
test.skip('adds 2 and 2', () => {
9-
expect(calculator.add(2,2)).toBe(4);
8+
xit('adds 2 and 2', function() {
9+
expect(calculator.add(2,2)).toEqual(4);
1010
});
1111

12-
test.skip('adds positive numbers', () => {
13-
expect(calculator.add(2,6)).toBe(8);
12+
xit('adds positive numbers', function() {
13+
expect(calculator.add(2,6)).toEqual(8);
1414
});
1515
});
1616

17-
describe('subtract', () => {
18-
test.skip('subtracts numbers', () => {
19-
expect(calculator.subtract(10,4)).toBe(6);
17+
describe('subtract', function() {
18+
xit('subtracts numbers', function() {
19+
expect(calculator.subtract(10,4)).toEqual(6);
2020
});
2121
});
2222

23-
describe('sum', () => {
24-
test.skip('computes the sum of an empty array', () => {
25-
expect(calculator.sum([])).toBe(0);
23+
describe('sum', function() {
24+
xit('computes the sum of an empty array', function() {
25+
expect(calculator.sum([])).toEqual(0);
2626
});
2727

28-
test.skip('computes the sum of an array of one number', () => {
29-
expect(calculator.sum([7])).toBe(7);
28+
xit('computes the sum of an array of one number', function() {
29+
expect(calculator.sum([7])).toEqual(7);
3030
});
3131

32-
test.skip('computes the sum of an array of two numbers', () => {
33-
expect(calculator.sum([7,11])).toBe(18);
32+
xit('computes the sum of an array of two numbers', function() {
33+
expect(calculator.sum([7,11])).toEqual(18);
3434
});
3535

36-
test.skip('computes the sum of an array of many numbers', () => {
37-
expect(calculator.sum([1,3,5,7,9])).toBe(25);
36+
xit('computes the sum of an array of many numbers', function() {
37+
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
3838
});
3939
});
4040

41-
describe('multiply', () => {
42-
test.skip('multiplies two numbers', () => {
43-
expect(calculator.multiply([2,4])).toBe(8);
41+
describe('multiply', function() {
42+
xit('multiplies two numbers', function() {
43+
expect(calculator.multiply([2,4])).toEqual(8);
4444
});
4545

46-
test.skip('multiplies several numbers', () => {
47-
expect(calculator.multiply([2,4,6,8,10,12,14])).toBe(645120);
46+
xit('multiplies several numbers', function() {
47+
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
4848
});
4949
});
5050

51-
describe('power', () => {
52-
test.skip('raises one number to the power of another number', () => {
53-
expect(calculator.power(4,3)).toBe(64); // 4 to third power is 64
51+
describe('power', function() {
52+
xit('raises one number to the power of another number', function() {
53+
expect(calculator.power(4,3)).toEqual(64); // 4 to third power is 64
5454
});
5555
});
5656

fibonacci/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Exercise 10 - Fibonacci
1+
# Exercise XX - fibonacci
22

3-
Create a function that returns a specific member of the Fibonacci sequence:
3+
Create a function that returns a specific member of the fibonacci sequence:
44

5-
> A series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
5+
> a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
66
77
```javascript
88
fibonacci(4) // returns the 4th member of the series: 3 (1, 1, 2, 3)

0 commit comments

Comments
 (0)
0