Skip to content

Commit

Permalink
fix(utils/get-most-frequent-items): getting items
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnigos committed Nov 24, 2023
1 parent 22d414e commit bb24a58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/common/types/spotify/profile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SpotifyImage } from '.'
import { SpotifyImage } from './image'

export interface FormattedProfile {
id: string
displayName: string
images: SpotifyImage[]
images?: SpotifyImage[]
followers: number
country?: string
email?: string
Expand Down
7 changes: 6 additions & 1 deletion src/utils/get-most-frequent-items.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function getMostFrequentItems(array: string[], limit = 1) {
console.log(array)

if (array.length === 0) return array

const frequencies = {}
Expand All @@ -21,8 +23,11 @@ export function getMostFrequentItems(array: string[], limit = 1) {
const mostFrequentItems = []

for (let index = 0; index < limit; index++) {
mostFrequentItems.push(frequencyArray[index][1])
console.log(frequencyArray[index])
frequencyArray[index] && mostFrequentItems.push(frequencyArray[index]?.[1])
}

console.log(mostFrequentItems)

return mostFrequentItems
}

0 comments on commit bb24a58

Please sign in to comment.