๐Ÿค ์€์ง€log ๐Ÿค

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค:Javascript] ๋ฐฐ์—ด์˜ ํ‰๊ท ๊ฐ’ ๋ณธ๋ฌธ

๐ŸŒˆ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค:Javascript] ๋ฐฐ์—ด์˜ ํ‰๊ท ๊ฐ’

Eun_zii 2023. 1. 4. 14:13

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv.0

- ๋ฐฐ์—ด์˜ ํ‰๊ท ๊ฐ’

 

๐Ÿ’š ๋ฌธ์ œ์„ค๋ช…

  • ์ •์ˆ˜ ๋ฐฐ์—ด numbers๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. numbers์˜ ์›์†Œ์˜ ํ‰๊ท ๊ฐ’์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.

 

๐Ÿ’š ์ œํ•œ์กฐ๊ฑด

  • 0 ≤ numbers์˜ ์›์†Œ ≤ 1,000
  • 1 ≤ numbers์˜ ๊ธธ์ด ≤ 100
  • ์ •๋‹ต์˜ ์†Œ์ˆ˜ ๋ถ€๋ถ„์ด .0 ๋˜๋Š” .5์ธ ๊ฒฝ์šฐ๋งŒ ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค.

 

๐Ÿ’š ๋ฌธ์ œ

function solution(numbers) {
    var answer = 0;
    return answer;
}

 

๐Ÿ’š ํ’€์ด

function solution(numbers) {
   return numbers.reduce((acc, cur) => acc + cur) / numbers.length
}

 

 
728x90