Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created November 26, 2018 11:03
Show Gist options
  • Save harrisonmalone/3153c3afd5d6200fbb31f845ae061f22 to your computer and use it in GitHub Desktop.
Save harrisonmalone/3153c3afd5d6200fbb31f845ae061f22 to your computer and use it in GitHub Desktop.
// 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