JSFiddle - React, Tailwind, and code Playground

by vaibhav2812

JavaScript

function ChainingOper(num) {
  this.square = () => {
    return Math.pow(num, 2);
  }
  this.double = () => {
    return num * 2;
  }
  this.add = () => {
    return num + 1;
  }
}

var chain = new ChainingOper(3).square().double();
console.log(chain);

var animals = ["cat", "dog", "fish"];
var threeLetterAnimals = [];
for (let count = 0; count < animals.length; count++) {
  if (animals[count].length === 3) {
    animals.push(animals[count]);
  }
}
cosnole.log(threeLetterAnimals);