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 115f3f7

Browse files
chaerin-devprove-ability
authored andcommitted
Add 문자열-다루기-기본.js
1 parent 4067e2a commit 115f3f7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ function solution(s) {
3333

3434
return answer;
3535
}
36+
37+
//정답 4 - chaerin-dev
38+
function solution(s) {
39+
// 길이가 4 혹은 6이 아니면 false 반환
40+
if (s.length !== 4 && s.length !== 6) return false;
41+
// 각 자리중에 숫자가 아닌 것이 하나라도 있으면 false 반환
42+
for (let i = 0; i < s.length; i++) {
43+
if (isNaN(Number(s[i]))) return false;
44+
}
45+
// 위의 모든 조건에 포함되지 않으면
46+
// (길이가 4 혹은 6이고, 숫자로만 구성되어 있으면) true 반환
47+
return true;
48+
}

0 commit comments

Comments
(0)

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