Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidystephenson/49d35be6770ba2c767387438a65a66c2 to your computer and use it in GitHub Desktop.
Save davidystephenson/49d35be6770ba2c767387438a65a66c2 to your computer and use it in GitHub Desktop.
// 7. Declare an object named "toy" with an empty object as its initial value.
// Add the properties "name" and "category" with values "Super Space Rocket" and "Action Figures & Playsets" respectively.
var toy = {}
toy.name = 'Super Space Rocket'
toy.category = 'Action Figures & Playsets'
console.log(toy)
function describeToy (toy, name, category) {
toy.name = name
toy.category = category
console.log(toy)
}
describeToy({}, 'Ball', 'Sports')
describeToy({}, 'Robot', 'Electronics')
function toyFactory (name, category) {
var toy = {}
toy.name = name
toy.category = category
return toy
}
const dollToy = toyFactory('Baby Doll', 'Dolls')
console.log(dollToy)
const carToy = toyFactory('Race car', 'Cars')
console.log(carToy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment