feat:3주차 과제 완료 - 도서 데이터 처리 시스템#1
Open
kyuwani wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
도서 데이터 처리 시스템 과제 제출
과제 내용
JavaScript 심화 과제 - 도서 데이터 처리 시스템 구현
구현한 함수
PART 1. 배열과 배열 메서드
getTitlesByCategory()- 카테고리별 책 제목 추출getTotalPriceAbove()- 가격 합계 계산isAllSameCategory()- 동일 카테고리 여부 확인PART 2. 구조 분해 할당
formatBookLabel()- 도서 라벨 포맷splitFirstAndRest()- 첫 번째 책과 나머지 분리omitPrice()- 가격 필드 제거PART 3. Map과 Set
groupByCategory()- 카테고리별 그룹화 (Map)intersection()- 두 배열의 교집합unique()- 중복 제거PART 4. Object 유틸
getOutOfStock()- 재고 없는 책 목록getTotalStock()- 전체 재고 합산removeNullish()- null/undefined 키 제거PART 5. 배열 메서드 심화 ★
getAvgPriceByCategory()- 카테고리별 평균 가격sortBy()- 특정 키 기준 정렬flattenCategories()- 중첩 카테고리 평탄화PART 6. 이터러블 & 페이지네이션 ★★
createBookIterator()- 이터레이터 생성paginate()- 페이지네이션 처리과제 수행 후기
어려웠던 점:
새롭게 배운 점:
리뷰어가 중점적으로 봐줬으면 하는 점:
셀프 체크리스트
npm test를 실행하여 모든 테스트가 통과하는지 확인했습니다.for반복문 대신 배열 메서드(filter,map,reduce등)를 사용했습니다.module.exports블록을 수정하지 않았습니다.console.log가 남아 있지 않습니다.🔗 관련 파일
index.js- 메인 구현 파일index.test.js- Jest 테스트 파일어려웠던 점
Object 유틸 함수를 구현하는 과정에서 테스트 결과가
undefined로 나오는 오류를 해결하는 데 어려움을 느꼈다.문제 상황
getTotalStock은 재고 합계 숫자를 반환해야 하고,removeNullish는null과undefined를 제거한 객체를 반환해야 했지만 테스트 결과가 모두undefined로 출력되었다.원인
함수 내부에서 값을 처리하는 로직은 작성했지만, 최종 결과를
return하지 않아 기대값이 반환되지 않았다.해결 방법
getTotalStock은Object.values()와reduce()를 사용해 재고 수량의 합계를 반환하도록 수정했다.removeNullish는Object.entries()와filter()를 사용해null과undefined값만 제외한 새 객체를 반환하도록 수정했다.배운 점
이번 오류를 통해 함수 구현 시 로직 작성뿐만 아니라 최종 결과를 명확히 반환하는 것이 중요하다는 점을 배웠다.