// Practice Set · JS Maps · guest

Guest practice: this set is not saved and does not count.

Question 1 of 5 from: JS Maps

What does this log?

const m = new Map();
m.set(1, "number");
m.set("1", "string");
const o = {};
o[1] = "number";
o["1"] = "string";
console.log(m.size, Object.keys(o).length);
Question 2 of 5 from: JS Maps

What does this log?

const plain = {};
const map = new Map();
console.log("constructor" in plain, map.has("constructor"));
Question 3 of 5 from: JS Map Methods

What does this log?

const apples = { name: "Apples" };
const prices = new Map([[apples, 500]]);
console.log(prices.get(apples), prices.get("apples"));
Question 4 of 5 from: JS Map WeakMap

What does this log?

const wm = new WeakMap();
const k = {};
wm.set(k, 1);
console.log(wm.get(k), wm.has({}), wm.size);
Question 5 of 5 from: JS Map WeakMap

What does this log?

const visits = new WeakMap();
const paul = { name: "Paul" };
function track(person) {
  visits.set(person, (visits.get(person) ?? 0) + 1);
}
track(paul);
track(paul);
track(paul);
console.log(visits.get(paul));
Ready to submit?

Click a question to go back and check it. After you submit, you will see the right answer and an explanation for every question. As a guest, nothing is saved.