InstruçÔes
Hash de dois arrays
Dados dois arrays, crie um objeto hash onde os elementos de um array (as chaves) estejam ligados aos elementos do outro array (os valores).
Exemplo:
const firstArr = [1, 2, 3];
const secondArr = ["a", "b", "c"];
const hashObj = arrToObj(firstArr, secondArr);
O objeto hash criado a partir dos arrays acima serĂĄ {1: "a", 2: "b", 3: "c"}.
O que fazer:
Testes:
- `arrToObj` deve ser uma função.
- `arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d", "e"])` deve retornar `{ 1: "a", 2: "b", 3: "c", 4: "d", 5: "e" }`
- `arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d"])` deve retornar `{ 1: "a", 2: "b", 3: "c", 4: "d", 5: undefined }`
- `arrToObj([1, 2, 3], ["a", "b", "c", "d", "e"])` deve retornar `{ 1: "a", 2: "b", 3: "c" }`
- `arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4, 5])` deve retornar `{ "a": 1, "b": 2, "c": 3 , "d": 4, "e": 5 }`
- `arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4])` deve retornar `{ "a": 1, "b": 2, "c": 3 , "d": 4, "e": undefined }`
- `arrToObj(["a", "b", "c"], [1, 2, 3, 4, 5])` deve retornar `{ "a": 1, "b": 2, "c": 3 }`
Console