silvana1303

cats

Apr 13th, 2021
509
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr){
  2.  
  3.     let catArray = [];
  4.  
  5.     class Cat {
  6.         constructor(name, age) {
  7.             this.name = name;
  8.             this.age = age;
  9.             this.speak = () => {
  10.                 console.log(`${this.name}, age ${this.age} says Meow`);
  11.             }
  12.         }
  13.  
  14.  
  15.     }
  16.  
  17.     for (let i = 0; i < arr.length; i++) {
  18.         let data = arr[i].split(' ');
  19.         let name = null;
  20.         let age = null;
  21.         [name, age] = [data[0], data[1]];
  22.         catArray.push(new Cat(name, age));
  23.     }
  24.  
  25.     for (let argument of catArray) {
  26.         argument.speak();
  27.     }
  28.  
  29.  
  30. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×