복잡한 조건에 이름 붙이기 | Frontend Fundamentals #81
Replies: 5 comments 1 reply
-
중요한 내용이네요 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
안녕하세요! 유익한 글 감사합니다. const matchedProducts = products.filter((product) => {
return product.categories.some((category) => {
const isSameCategory = category.id === targetCategory.id;
const isPriceInRange = product.prices.some(
(price) => price >= minPrice && price <= maxPrice
);
return isSameCategory && isPriceInRange;
});
}); 위 코드에서 |
Beta Was this translation helpful? Give feedback.
-
위 개선 코드 중 |
Beta Was this translation helpful? Give feedback.
-
const matchedProducts = products.filter(product => { // 2) 일치하는 제품에 대해서만 가격 범위 검사 // 3) ... 이후에 추가되는 검사 로직 Huinno-joonhonoh님께서 말씀해주신것 처럼 some 루프를 분리시키면 가독성이나 추후 확장성이 더 좋아질것 같습니다!! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
복잡한 조건에 이름 붙이기 | Frontend Fundamentals
변경하기 쉬운 프론트엔드 코드를 위한 지침서
https://frontend-fundamentals.com/code/examples/condition-name.html
Beta Was this translation helpful? Give feedback.
All reactions