Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createAssemblyLine() {
- return { // This is the object that the factory function returns.
- hasClima(myCar) { // This is one of the methods of the object.
- myCar.temp = 21;
- myCar.tempSettings = 21;
- myCar.adjustTemp = () => {
- if (myCar.temp < myCar.tempSettings) {
- myCar.temp++;
- } else if (myCar.temp > myCar.tempSettings) {
- myCar.temp--;
- }
- }
- },
- hasAudio(myCar) {
- myCar.currentTrack = {
- name: null,
- artist: null
- }
- myCar.nowPlaying = () => {
- if (myCar.currentTrack !== null) {
- console.log(`Now playing '${myCar.currentTrack.name}' by ${myCar.currentTrack.artist}`);
- }
- }
- },
- hasParktronic(myCar) {
- myCar.checkDistance = (distance) => {
- if (distance < 0.1) {
- console.log("Beep! Beep! Beep!");
- } else if (0.1 <= distance) {
- console.log("Beep! Beep!");
- } else if (0.25 <= distance) {
- console.log("Beep!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement