Skip to content

Commit

Permalink
Refactor SORTING_LIST creation to use map instead of forEach for impr…
Browse files Browse the repository at this point in the history
…oved readability
  • Loading branch information
pdcp1 committed Dec 12, 2024
1 parent c815d83 commit 34b8401
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions site/gatsby-site/src/components/discover/SORTING_LISTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ const BASE_SORTING_LIST = [
},
];

const SORTING_LIST = [];

BASE_SORTING_LIST.forEach((item) => {
const SORTING_LIST = BASE_SORTING_LIST.map((item) => {
const newItem = {
...item,
value: `instant_search-en${item.instantKey == 'featured' ? '-' : '_'}${item.instantKey}`,
Expand All @@ -80,7 +78,7 @@ BASE_SORTING_LIST.forEach((item) => {
// remove auxiliary field
delete newItem.instantKey;

SORTING_LIST.push(newItem);
return newItem;
});

export default SORTING_LIST;

0 comments on commit 34b8401

Please sign in to comment.