Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- RN새로운아키텍쳐
- react-native-image-picker
- named type
- Promise
- no-permission-handler-detected
- rn
- javascript
- react
- private-access-to-photos
- CS
- react native
- motion.div
- ios
- RN아키텍쳐
- axios
- react-native
- 비동기
- RN업데이트
- hydration mismatch
- react-native-permissions
- debounce
- Hash-table
- React-Native업데이트
- async
- await
- promise.all
- animation
- react animation
- Throttle
- Swift
Archives
- Today
- Total
하루살이 개발일지
[Algorithm] 평균 구하기 본문
문제 설명
정수를 담고 있는 배열 arr의 평균값을 return하는 함수, solution을 완성해보세요.
제한사항
- arr은 길이 1 이상, 100 이하인 배열입니다.
- arr의 원소는 -10,000 이상 10,000 이하인 정수입니다.
입출력 예
arr return
[1,2,3,4] | 2.5 |
[5,5] | 5 |
정답
function solution(arr) {
return arr.reduce((a, c) => a + c, 0) / arr.length;
}
'알고리즘' 카테고리의 다른 글
[Algorithm] 문자열 내림차순으로 배치하기 (0) | 2023.06.19 |
---|---|
[Algorithm] 핸드폰 번호 가리기 (0) | 2023.06.18 |
[Algorithm] 음양 더하기 - 프로그래머스 (0) | 2023.06.18 |
[Algorithm] 없는 숫자 더하기 - 프로그래머스 (0) | 2023.06.18 |
[Algorithm] 문자열을 정수로 바꾸기 (0) | 2023.06.18 |