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

[Codewars] Array plus array (8 kyu) / JavaScript

by fluss 2023. 2. 21.

https://www.codewars.com/kata/5a2be17aee1aaefe2a000151

 

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:

I'm new to coding and now I want to get the sum of two arrays... Actually the sum of all their elements. I'll appreciate for your help.

P.S. Each array includes only integer numbers. Output is a number too.

 

코드

function arrayPlusArray(arr1, arr2) {
  return arr1.concat(arr2).reduce((a, b) => a + b, 0);
}

댓글