Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 334becd

Browse files
가운데-글자-가져오기 - 솔루션 추가
1 parent 9b89cf0 commit 334becd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎level-1/가운데-글자-가져오기.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@ function solution(s) {
66
const length = s.length
77
answer = (length % 2) !== 0 ? s[Math.floor(length / 2)] : s.slice((length / 2) - 1, (length / 2) + 1)
88
return answer;
9-
}
9+
}
10+
11+
//정답 2 - yongchanson
12+
function solution(s) {
13+
var answer = "";
14+
let L2 = s.length / 2;
15+
16+
answer =
17+
s.length % 2 == 0 ? s[L2 - 1] + s[L2] : (answer = s[Math.ceil(L2 - 1)]);
18+
19+
return answer;
20+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /