Let's learn how to iterate over the objects and how to access and create new properties.
This time tasks are given as the comments in the script:
MDN - Objects - dot and bracket notation
Let's learn how to iterate over the objects and how to access and create new properties.
This time tasks are given as the comments in the script:
MDN - Objects - dot and bracket notation
var joke = { | |
category: 'Chuck Norris Jokes', | |
url: 'https://api.chucknorris.io/jokes/I5_UU3f7Q2e2qao2TJz9aw', | |
content: 'Anything you can do, Chuck Norris does better.' | |
} | |
// Task 1 | |
// Using `for..in`, `console.log` all property names of the `joke` object, | |
// concatenating string `joke.` first. | |
// Expected result : 'joke.category', `joke.url`, `joke.content` | |
// Task 2 | |
// Using `Object.keys` get the array of property names (keys) from the object joke | |
// and `console.log` that array. | |
// Task 3 | |
// Using keyword `delete`, remove the property `url` from the object joke. | |
// Task 4 | |
// Using dot notation add method (function) `hint` to the joke object. | |
// Method should `console.log`: "The joke is stored in the property .content" |