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 eff3998

Browse files
authored
Update 문자열-다루기-기본&12918&.js
1 parent bf55435 commit eff3998

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,19 @@ function solution(s) {
4343
// 위의 모든 조건에 포함되지 않으면
4444
// (길이가 4 혹은 6이고, 숫자로만 구성되어 있으면) true 반환
4545
return true;
46-
}
46+
}
47+
48+
//정답 5 - soulhn
49+
function solution(s) {
50+
// 길이가 4이거나 6인지 확인
51+
if (s.length === 4 || s.length === 6) {
52+
//배열로 변환, Int로 변환, 배열 내부에 NaN이 있는지 확인
53+
//NaN이 존재하면 true 반환이기에 ! 이용하여 false 반환
54+
return !s
55+
.split("")
56+
.map((i) => parseInt(i, 10))
57+
.includes(NaN);
58+
} else { //길이가 4, 6이 아니면 false 반환
59+
return false;
60+
}
61+
}

0 commit comments

Comments
(0)

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