Skip to content

Commit

Permalink
converts strings to numbers and correctly compares the values
Browse files Browse the repository at this point in the history
  • Loading branch information
Carolina Capetillo authored and Carolina Capetillo committed Sep 27, 2023
1 parent d117cb1 commit 4d84cbc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/store/modules/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ const getters = {
const maxSSTKNUMs = state.recent_images.reduce((acc, cur) => {
if (!cur.header || !cur.header.SMARTSTK || !cur.header.SSTKNUM) return acc // Skip if missing header, SMARTSTK or SSTKNUM

if (!acc[cur.header.SMARTSTK] || Number(cur.header.SSTKNUM) > Number(acc[cur.header.SMARTSTK])) {
acc[cur.header.SMARTSTK] = cur.header.SSTKNUM
const num = parseInt(cur.header.SSTKNUM) // convert string to number
if (!acc[cur.header.SMARTSTK] || num > acc[cur.header.SMARTSTK]) {
acc[cur.header.SMARTSTK] = num
}
return acc
}, {})
Expand Down

0 comments on commit 4d84cbc

Please sign in to comment.