문제
Map, Filter, Reduce - Code Exercises | CroCoder
Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises!
www.crocoder.dev
정답
const input = [12, 46, 32, 64];
const mean = input.reduce((a, b) => a + b) / input.length;
const median = Math.round(mean);
console.log(`{mean : ${mean}, median : ${median}}`);
const input = [12, 46, 32, 64];
const obj = {};
obj.mean = input.reduce((a, b) => a + b) / input.length;
obj.median = Math.round(obj.mean);
console.log(obj);