Sobes.tech
Назад к вопросам
Middle+
2

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

Ответ от нейросети

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 }