Kata
Check to see if a string has the same amount of ‘x’s and ‘o’s. The method must return a boolean and be case insensitive. The string can contain any char.
Example:1
2
3
4
5XO("ooxx") => true
XO("xooxx") => false
XO("ooxXm") => true
XO("zpzpzpp") => true // when no 'x' and 'o' is present should return true
XO("zzoo") => false
# My Solutions
1 | function XO(str) { |
# Others
정규식으로 풀이
1 | function XO(str) { |
split() 사용
1 | function XO(str) { |
# thoughts
- split() 사용한 풀이는 굉장히 새로웠다.
split의 반환값(return)은 배열.
위의 풀이는 x, o 를 각각 제외한 배열의 길이로 구현