본문 바로가기
알고리즘/Codewars

[Codewars] Beginner - Reduce but Grow (8 kyu) / JavaScript

by fluss 2023. 1. 23.

https://www.codewars.com/kata/57f780909f7e8e3183000078

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

Given a non-empty array of integers, return the result of multiplying the values together in order. Example:

[1, 2, 3, 4] => 1 * 2 * 3 * 4 = 24
 

코드

function grow(x){
  return x.reduce((acc, cur) => acc * cur, 1);
}

댓글