Factory Functions <3

PHOTO EMBED

Tue Oct 05 2021 17:42:24 GMT+0000 (Coordinated Universal Time)

Saved by @ianvalentino #javascript #factoryfunctions

const robotFactory = (model, mobile) => {
  return {
    model: model,
    mobile: mobile,
    beep() {
      console.log('Beep Boop');
    }
  }
};

const tinCan = robotFactory('P-500', true);

tinCan.beep();
content_copyCOPY

https://www.codecademy.com/courses/introduction-to-javascript/lessons/advanced-objects/exercises/factory-functions