Last active
May 17, 2025 17:08
-
-
Save davidystephenson/49d35be6770ba2c767387438a65a66c2 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
// 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