You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When looking at your code, I don't know what compareFunc compares, and it was a surprise to me when I saw its use as compareFunc().map(). It's surprising that it returns an array, since its name implies it'd be used as a callback. E.g. someone would expect something like, compareFunc(a, b) => return a > b
Something like compareAndReturnFeatures, getUniqueFeatures, etc. would be more clear.
Avoid having 'magic numbers'. I have no idea what arr[0] and arr[1] are - set variables instead so the reader doesn't have to guess.
Try to use array methods like .forEach, .map, .filter, etc. as much as you can. Imperative for-loops are difficult to read and can be error prone in implementation. Even for
ProjectCatwalk/client/src/components/RelatedProducts/Modal.jsx
Line 20 in 88b5d24
Couple things:
When looking at your code, I don't know what
compareFunc
compares, and it was a surprise to me when I saw its use ascompareFunc().map()
. It's surprising that it returns an array, since its name implies it'd be used as a callback. E.g. someone would expect something like,compareFunc(a, b) => return a > b
Something like
compareAndReturnFeatures
,getUniqueFeatures
, etc. would be more clear.Avoid having 'magic numbers'. I have no idea what
arr[0]
andarr[1]
are - set variables instead so the reader doesn't have to guess.Try to use array methods like .forEach, .map, .filter, etc. as much as you can. Imperative for-loops are difficult to read and can be error prone in implementation. Even for
It's just easier to read
The text was updated successfully, but these errors were encountered: