Advertisement
ErolKZ

Untitled

Jan 20th, 2022
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1.  
  2. function createAssemblyLine() {
  3.  
  4.  
  5. return { // This is the object that the factory function returns.
  6.  
  7. hasClima(myCar) { // This is one of the methods of the object.
  8.  
  9. myCar.temp = 21;
  10.  
  11. myCar.tempSettings = 21;
  12.  
  13. myCar.adjustTemp = () => {
  14.  
  15. if (myCar.temp < myCar.tempSettings) {
  16.  
  17. myCar.temp++;
  18.  
  19. } else if (myCar.temp > myCar.tempSettings) {
  20.  
  21. myCar.temp--;
  22.  
  23. }
  24.  
  25. }
  26.  
  27. },
  28.  
  29.  
  30. hasAudio(myCar) {
  31.  
  32. myCar.currentTrack = {
  33.  
  34. name: null,
  35.  
  36. artist: null
  37.  
  38. }
  39.  
  40. myCar.nowPlaying = () => {
  41.  
  42. if (myCar.currentTrack !== null) {
  43.  
  44. console.log(`Now playing '${myCar.currentTrack.name}' by ${myCar.currentTrack.artist}`);
  45.  
  46. }
  47.  
  48. }
  49.  
  50. },
  51.  
  52.  
  53. hasParktronic(myCar) {
  54.  
  55. myCar.checkDistance = (distance) => {
  56.  
  57. if (distance < 0.1) {
  58.  
  59. console.log("Beep! Beep! Beep!");
  60.  
  61. } else if (0.1 <= distance) {
  62.  
  63. console.log("Beep! Beep!");
  64.  
  65. } else if (0.25 <= distance) {
  66.  
  67. console.log("Beep!");
  68.  
  69. }
  70.  
  71.  
  72. }
  73.  
  74. }
  75.  
  76. }
  77.  
  78.  
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement