Answers for "turn 2 arrays into a dictionary javascript"

0

javascript dictionary from two arrays

var keys = ['foo', 'bar', 'baz'];
var values = [11, 22, 33]

var result = {};
keys.forEach((key, i) => result[key] = values[i]);
console.log(result);
Posted by: Guest on May-13-2020
0

merge 2 dictionaries with same keys javascript

const target = { a: [1], b: [2] };
const source = { a: [2], c: [5] };

const returnedTarget = Object.assign(target, source);

for(var date in source)
target[date] = [...target[date] || [],...source[date]]

console.log(target);
Posted by: Guest on September-13-2021

Code answers related to "turn 2 arrays into a dictionary javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language