Show the property names joined by commas.
Acceptance criteria
- 1.#out should show name,age.
JavaScript Tutorial · JavaScript Objects
These 10 tasks go with the JavaScript Object keys and values 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: “Object.keys, Object.values and Object.entries turn an object into arrays you can loop over.” .
1.List the keysexercise · easy · 10 min
Show the property names joined by commas.
Passes when: #out should show name,age.
2.List the valuesexercise · easy · 10 min · practice plan
Show the property values joined by commas.
Passes when: #out should show Ada,36.
3.Count the propertiesexercise · easy · 10 min · practice plan
Show how many properties an object has.
Passes when: #out should show 3.
4.Total the valuesexercise · easy · 10 min · practice plan
Add up every value in a scores object.
Passes when: #out should show 90.
5.Loop over entriesexercise · medium · 10 min · practice plan
Build a string of each key and value, separated by spaces.
Passes when: #out should show maths=30 art=35.
6.Fix length used on an objectbug fix · easy · 8 min
Objects have no length property.
Passes when: #out should show 3.
7.Fix keys used instead of valuesbug fix · easy · 8 min · practice plan
The names are being totalled, not the numbers.
Passes when: #out should show 90.
8.Fix the method called on the objectbug fix · easy · 8 min · practice plan
These are functions on Object, not methods of your object.
Passes when: #out should show name,age.
9.Fix entries not unpackedbug fix · easy · 8 min · practice plan
Each entry is a pair, so it needs destructuring.
Passes when: #out should show maths=30 art=35.
10.Fix values used instead of keysbug fix · easy · 8 min · practice plan
The property names are wanted, not the numbers.
Passes when: #out should show maths,art.
Between them these tasks cover Object.keys, Object.values and Object.entries.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.