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 f24fae2

Browse files
jaewon1676prove-ability
authored andcommitted
Update 수박수박수박수박수박수?.js
1 parent 36e38fe commit f24fae2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎level-1/수박수박수박수박수박수.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ function solution(n) {
1414
// "수박"을 n번 반복한 문자열의 0번 인덱스부터 n만큼 추출해서 반환
1515
return "수박".repeat(n).substr(0, n);
1616
}
17+
18+
//정답 3 - jaewon1676
19+
function solution(n) {
20+
let str = '';
21+
for (let i=0; i<n; i++){
22+
// 삼항 연산자와 +로 문자열을 붙여주어 추가.
23+
(i % 2 == 0 ? str = str + '수' : str = str + '박')
24+
}
25+
return str;
26+
}

0 commit comments

Comments
(0)

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