let a1 = [1, 3, 5];
let a2 = {1: "a", 2: "b", 3: "c", 4: "d", 5: 2,}
// pass a function to map
const map1 = a1.map(? => ?);
console.log(map1);
// expected output: Array ["a", "c", 2]
I want the number in the array 1, 3, 5 to map to the values on the keys of a2
What should "? => ?" be for the desired result?
Edited
My question is after reading the documentation Array.prototype.map() in MDN.
My question is (not how to solve this) but to learn about the callback function in .map():
let a1 = [1, 3, 5];
let a2 = {1: "a", 2: "b", 3: "c", 4: "d", 5: 2,}
// pass a function to map
const map1 = a1.map(a2, e => a2.value);
console.log(map1);
// expected output: Array ["a", "c", 2]
Here I wanted e in a1 to match a2 and return a2 in the map function, but it's clearly wrong but after Googling for examples I guess I just had to make a question about it and try not cause too much confusion.