Middle+
21
Implement a function foo that takes an array and returns an object where the keys are the elements of the array and the values are all 0.
Сұралған компаниялар
Mayflower
AI-дан жауап
sobes.tech AI
javascript function foo(arr) { return arr.reduce((acc, item) => { acc[item] = 0; return acc; }, {}); }
// Пример использования: const input = ['a', 'b', 'c']; const result = foo(input); console.log(result); // { a: 0, b: 0, c: 0 }