Complete the code to get an array of key-value pairs from the object.
const obj = {a: 1, b: 2};
const entries = Object.[1](obj);
console.log(entries);Use Object.entries(obj) to get an array of key-value pairs.
Complete the code to loop over the entries of the object.
const obj = {x: 10, y: 20};
for (const [key, value] of Object.[1](obj)) {
console.log(key, value);
}Use Object.entries(obj) to loop over key-value pairs.
Fix the error in the code to correctly get entries from the object.
const obj = {name: 'Alice', age: 25};
const entries = Object.[1](obj);
console.log(entries);The correct method name is entries. Typos cause errors.
Fill both blanks to create an object from entries and log it.
const entries = [['a', 1], ['b', 2]]; const obj = Object.[1](entries); console.[2](obj);
Use Object.fromEntries to create an object from entries and console.log to print it.
Fill all three blanks to filter entries with values greater than 10 and create a new object.
const obj = {a: 5, b: 15, c: 25};
const filteredEntries = Object.entries(obj).filter(([[1], [2]]) => [3] > 10);
const newObj = Object.fromEntries(filteredEntries);
console.log(newObj);Use key and value as variable names in destructuring, then filter by value > 10.
