What is your hint or solution suggestion?
Object.fromEntries
is from ES2019, which makes mapping array values to an object far easier. Only the index i
is needed.
Solution 1
function arrToObj (keys, vals) {
return Object.fromEntries(keys.map((_, i) => [keys[i], vals[i]]));
}
Challenge: Hash from two arrays
Link to the challenge: