const robotFactory = (model, mobile) => { return { model: model, mobile: mobile, beep(){ console.log('Beep Boop'); } } }; // parameters and entered in an order, check robotFactory const. const tinCan = robotFactory('P-500', true); tinCan.beep(); console.log(tinCan);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter