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 7b21a65

Browse files
Merge pull request codeisneverodd#105 from soulhn/soulhn-patch-1
Update 문자열-다루기-기본&12918&.js
2 parents 9b1b9f4 + 8e1fbe9 commit 7b21a65

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎level-1/문자열-다루기-기본&12918&.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ function solution(s) {
4343
// 위의 모든 조건에 포함되지 않으면
4444
// (길이가 4 혹은 6이고, 숫자로만 구성되어 있으면) true 반환
4545
return true;
46-
}
46+
}
47+
48+
//정답 5 - soulhn
49+
function solution(s) {
50+
if (s.length !== 4 && s.length !== 6) return false;
51+
return !s.split("").some((i) => isNaN(parseInt(i, 10)));
52+
//early return 제외사항 먼저 처리
53+
//.split 문자열 배열로 변환, .some을 이용하여 isNaN인지 판별, ! 사용하여 문제 조건에 맞게 반환
54+
}

0 commit comments

Comments
(0)

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