- calc/
calc.js- node_modules/
operations.jspackage-lock.jsonpackage.jsontest.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const assert = require('assert'); | |
| const operations = require('./operations'); | |
| // Test case for add() | |
| it('should calculates the sum of 1 and 3', () => { | |
| assert.equal(operations.add(1, 3), 4) | |
| }); | |
| // Test case for add() | |
| it('should return -2 to for added -1 and -1', () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nahid = new Man() | |
| console.log(nahid.mouth('rice')); // I eat rice | |
| console.log(nahid.eye('a drama')); // I watch a drama |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log(jamal.mouth('burger')); // I eat burger | |
| console.log(jamal.eye('TV')); // I watch TV | |
| console.log(jamal.leg('office')); // I go to office |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Creating jamal object from Man() class | |
| const jamal = new Man(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Declare a Man class | |
| class Man { | |
| hand(substance) { return `I grab the ${substance}` }; | |
| leg(path) { return `i go to ${path}` }; | |
| mouth(food) { return `I eat ${food}` }; | |
| eye(object) { return `I watch ${object}` }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Function declaration way | |
| function secondArea(length, width) { | |
| return length * width; | |
| } | |
| console.log(secondArea(20, 10)); // 200 | |
| //Using ES6 Arrow Function | |
| const thirdArea = (length, width) => length * width; | |
| console.log(thirdArea(20, 10)); // 200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Declare length and width | |
| const length = 5; | |
| const width = 10; | |
| // calculate area | |
| const firstArea = length * width; | |
| console.log(firstArea); // 50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Person = function(firstAndLast) { | |
| let firstName = firstAndLast.split(' ')[0]; | |
| let lastName = firstAndLast.split(' ')[1]; | |
| this.getFirstName = function(){ | |
| return firstName; | |
| }; | |
| this.getLastName = function(){ | |
| return lastName; |