Skip to content

Instantly share code, notes, and snippets.

View jaamaalxyz's full-sized avatar
🎯
Focusing

Md. Jamal Uddin jaamaalxyz

🎯
Focusing
View GitHub Profile
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', () => {
  • calc/
    • calc.js
    • node_modules/
    • operations.js
    • package-lock.json
    • package.json
    • test.js
const nahid = new Man()
console.log(nahid.mouth('rice')); // I eat rice
console.log(nahid.eye('a drama')); // I watch a drama
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
// Creating jamal object from Man() class
const jamal = new Man();
// 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}` };
}
// 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
// Declare length and width
const length = 5;
const width = 10;
// calculate area
const firstArea = length * width;
console.log(firstArea); // 50
var Person = function(firstAndLast) {
let firstName = firstAndLast.split(' ')[0];
let lastName = firstAndLast.split(' ')[1];
this.getFirstName = function(){
return firstName;
};
this.getLastName = function(){
return lastName;