Skip to content

Commit be0fad1

Browse files
committed
알고리즘 업데이트
1 parent dbab056 commit be0fad1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

4.점수계산.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(arr) {
9+
let answer = 0;
10+
let cnt = 0;
11+
12+
arr.forEach((ele, index) => {
13+
if (ele === 1) {
14+
cnt++;
15+
answer = answer + cnt;
16+
} else {
17+
cnt = 0;
18+
}
19+
});
20+
21+
return answer;
22+
}
23+
24+
let arr = [1, 0, 1, 1, 1, 0, 0, 1, 1, 0];
25+
console.log(solution(arr));
26+
</script>
27+
</body>
28+
</html>

0 commit comments

Comments
 (0)