Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findCardFrequency(str){
- var pattern = new RegExp(/\W/g);
- var strings = str[0].split(pattern).filter(Boolean);
- var resultArr = {};
- for(i=0;i<strings.length;i++){
- resultArr[strings[i]]=0;
- }
- for(i=0;i<strings.length;i++){
- resultArr[strings[i]]+=1;
- }
- console.log(resultArr)
- }
- findCardFrequency(['8♥ 2♣ 4♦ 10♦ J♥ A♠ K♦ 10♥ K♠ K♦']);
- findCardFrequency(['J♥ 2♣ 2♦ 2♥ 2♦ 2♠ 2♦ J♥ 2♠']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement