Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createAssemblyLine() {
- let assembly = {
- hasClima(car) {
- car.temp = 21;
- car.tempSettings = 21;
- car.adjustTemp = () => {
- if(car.temp < car.tempSettings) {
- car.temp++;
- } else if(car.temp > car.tempSettings) {
- car.temp--;
- }
- };
- },
- hasAudio(car) {
- car.currentTrack = {
- name: null,
- artist: null
- };
- car.nowPlaying = () => {
- console.log(`Now playing '${car.currentTrack.name}' by ${car.currentTrack.artist}`);
- };
- },
- hasParktronic(car) {
- car.checkDistance = (distance) => {
- if(distance < 0.1) {
- console.log("Beep! Beep! Beep!");
- } else if(distance >= 0.1 && distance < 0.25) {
- console.log("Beep! Beep!");
- } else if(distance >= 0.25 && distance < 0.5) {
- console.log("Beep!");
- } else {
- console.log('');
- }
- };
- }
- }
- return assembly;
- }
- const assemblyLine = createAssemblyLine();
- const myCar = {
- make: 'Toyota',
- model: 'Avensis'
- };
- console.log(myCar);
Add Comment
Please, Sign In to add comment