Created
November 26, 2018 11:03
-
-
Save harrisonmalone/3153c3afd5d6200fbb31f845ae061f22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a factory function (to create objects) that takes one argument. It should use that argument to set the value of the first key of the object. The second key should be given the value ‘red’. | |
function Car(brand) { | |
function printCar() { | |
console.log(`the brand of car is ${this.brand}`) | |
} | |
return { | |
brand: brand, | |
color: 'red', | |
printCar: printCar | |
} | |
} | |
let bmw = Car('bmw') | |
bmw.color = 'blue' | |
bmw.printCar() | |
console.log(bmw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment