Skip to content

Commit d8325bd

Browse files
authored
Update js codes.docx
1 parent 12afef5 commit d8325bd

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

js codes.docx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,6 +3189,17 @@ function countOccurance(arr){
31893189
return map
31903190
}
31913191
console.log(countOccurance([1, 4, 91, 21, 91, 0, 32, 4, 11, 3, 54, 34, 21]))
3192+
-------------------------------------------------------------------
3193+
var frequencySort = function(nums) {
3194+
const hash={}
3195+
for(let item of nums){
3196+
hash[item]
3197+
?hash[item]++
3198+
:hash[item]=1
3199+
}
3200+
return hash
3201+
};
3202+
console.log(frequencySort([1,1,2,2,2,3]))
31923203
==========================================================================================================================================================================
31933204

31943205

0 commit comments

Comments
 (0)