Back to questions
Middle+
3
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.
Companies where asked
Mayflower
Answer from 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 }