Create a person object with a name and show the name.
Acceptance criteria
- 1.#out should show Ada.
JavaScript Tutorial · JavaScript Objects
These 10 tasks go with the JavaScript Objects chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “A JavaScript object stores related values together as named properties.” .
1.Create an objectexercise · easy · 10 min
Create a person object with a name and show the name.
Passes when: #out should show Ada.
2.Read with bracketsexercise · easy · 10 min · practice plan
Read a property using a key held in a variable.
Passes when: #out should show Toyota.
3.Add a propertyexercise · easy · 10 min · practice plan
Add a year to a car object and show the brand and year together.
Passes when: #out should show Toyota 2021.
4.Check a missing propertyexercise · easy · 10 min · practice plan
Show the type of a property that was never set.
Passes when: #out should show undefined.
5.Delete a propertyexercise · medium · 10 min · practice plan
Delete one property and show how many are left.
Passes when: #out should show 1.
6.Fix the dot used with a variable keybug fix · easy · 8 min
A dot looks for a property literally named key.
Passes when: #out should show Toyota.
7.Fix the array bracketsbug fix · easy · 8 min · practice plan
Square brackets make an array, so the named properties are lost.
Passes when: #out should show Ada.
8.Fix the equals sign in the literalbug fix · easy · 8 min · practice plan
Object properties use a colon, not an equals sign.
Passes when: #out should show Toyota 2021.
9.Fix the misspelled propertybug fix · easy · 8 min · practice plan
The name is read with a typo, so nothing is found.
Passes when: #out should show Ada.
10.Fix the property never removedbug fix · easy · 8 min · practice plan
Setting a property to undefined leaves it in place.
Passes when: #out should show 1.
Between them these tasks cover Object literals, Dot notation and Bracket notation.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.