0
0
Javascriptprogramming~10 mins

Object keys and values in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get all keys from the object.

Javascript
const obj = {a: 1, b: 2, c: 3};
const keys = Object.[1](obj);
console.log(keys);
Drag options to blanks, or click blank then click option'
Akeys
BgetKeys
Centries
Dvalues
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using Object.values instead of Object.keys
Trying to call a non-existent method like Object.getKeys
2fill in blank
medium

Complete the code to get all values from the object.

Javascript
const obj = {x: 10, y: 20, z: 30};
const vals = Object.[1](obj);
console.log(vals);
Drag options to blanks, or click blank then click option'
Avalues
Bkeys
Centries
DgetValues
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using Object.keys instead of Object.values
Trying to call a non-existent method like Object.getValues
3fill in blank
hard

Fix the error in the code to get entries from the object.

Javascript
const obj = {name: 'Alice', age: 25};
const entries = Object.[1](obj);
console.log(entries);
Drag options to blanks, or click blank then click option'
Akeys
Bvalues
Centries
DgetEntries
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using Object.getEntries which does not exist
Using Object.keys or Object.values instead of Object.entries
4fill in blank
hard

Fill both blanks to create an object from entries and get its keys.

Javascript
const entries = [['a', 1], ['b', 2]];
const obj = Object.[1](entries);
const keys = Object.[2](obj);
console.log(keys);
Drag options to blanks, or click blank then click option'
AfromEntries
Bvalues
Ckeys
Dentries
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using Object.entries instead of Object.fromEntries
Using Object.values instead of Object.keys to get keys
5fill in blank
hard

Fill all three blanks to filter object keys with values greater than 10.

Javascript
const data = {a: 5, b: 15, c: 25};
const filteredKeys = Object.[1](data)
  .filter(key => data[key] [2] 10)
  .map(key => key.[3]());
console.log(filteredKeys);
Drag options to blanks, or click blank then click option'
Akeys
B>
CtoUpperCase
Dvalues
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using Object.values instead of Object.keys to get keys
Using '<' instead of '>' in filter condition
Using toLowerCase instead of toUpperCase