Skip to content
Open
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
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Let's practice modules
## Setup
* yarn install
* DONE --- yarn install

## Do
* Implement code for subtract module
* Add file and implement code for multiply module
* Add file and implement code for divide module
* Implement code for addOne in the addNumbers module
* Import and use addOne in index.js
* Add file and implmemnt code for subtractNumbers module
* Run yarn start
* Make sure there are no errors

* DONE --- Implement code for subtract module
* DONE --- Add file and implement code for multiply module
* DONE --- Add file and implement code for divide module
* DONE --- Implement code for addOne in the addNumbers module
* DONE --- Import and use addOne in index.js
* DONE --- Add file and implement code for subtractNumbers module
* DONE --- Run yarn start
* DONE --- Make sure there are no errors
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import add from "./modules/add";
import subtract from "./modules/subtract";
import multiply from "./modules/multiply";
import {addTen, addFive} from "./modules/addNumbers";
import {subtractOne} from "./modules/subtractNumbers";
import divide from "./modules/divide";
import {addTen, addFive, addOne} from "./modules/addNumbers";
import {subtractOne, subtractFive, subtractTen} from "./modules/subtractNumbers";

const number1 = 393;
const number2 = 238;
Expand Down
4 changes: 4 additions & 0 deletions src/modules/addNumbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export function addTen(num) {
export function addFive(num) {
return add(num, 5);
}

export function addOne(num) {
return add(num, 1);
}
5 changes: 5 additions & 0 deletions src/modules/divide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

function divide(num1, num2) {
return num2 / num1;
}
export default divide;
6 changes: 6 additions & 0 deletions src/modules/multiply.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

function multiply(num1, num2) {
return num2 * num1;
}

export default multiply;
6 changes: 6 additions & 0 deletions src/modules/subtract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

function subtract(num1, num2) {
return num2 - num1;
}

export default subtract;
13 changes: 13 additions & 0 deletions src/modules/subtractNumbers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import subtract from "./subtract";

export function subtractTen(num) {
return subtract(num,10);
}

export function subtractFive(num) {
return subtract(num, 5);
}

export function subtractOne(num) {
return subtract(num, 1);
}