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 b948b28

Browse files
Add 문자열-내-p와-y의-개수.js
1 parent 8a2a3da commit b948b28

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎level-1/문자열-내-p와-y의-개수.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ function solution(s) {
2727
// 문자열에서 특정 문자의 개수를 구하려면 split을 사용하면 된다.
2828
// Ex. "ababb".split("a") 의 결과는 ["", "b", "bb"]
2929
// => 즉, "a"의 갯수는 3에서 1을 뺀 2
30+
31+
// 정답 4 - prove-ability
32+
function solution(s){
33+
// 배열로 변환
34+
s = s.split("");
35+
// filter 를 사용해 갯수 추출
36+
const pCount = s.filter((v) => v === "p" || v === "P").length;
37+
const yCount = s.filter((v) => v === "y" || v === "Y").length;
38+
return pCount === yCount;
39+
}

0 commit comments

Comments
(0)

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