// 1. 원화 표기
// 2. 1000원 초과 리스트만 출력
// 3. 가격 순 정렬
const price = ['1000', '1000', '3000', '5000', '4000'];
// 1000원 초과 리스트만 출력
const suffixWon = (price) => price + '원';
const isOverOneThouand = (price) => price > '1000'
const ascendingList = (a, b) => a - b;
function getWonPrice(price){
// 먼저 1000원이상 거른다.
const isOverList = priceList.filter(isOverOneThouand)
// 가격 순 정렬을 해줌
const sortList = isOverList.sort(ascendingList)
// 먼저 1000원이상 거른 배열로 Map함수를 돌린다.
return sortList.map(suffixWon)
}
// 1000원 초과 리스트만 출력
const suffixWon = (price) => price + '원';
const isOverOneThouand = (price) => price > '1000'
const ascendingList = (a, b) => a - b;
function getWonPrice(priceList){
// 배열 메서드 체이닝을 한다.
return priceList.filter(isOverOneThouand) // filter 원하는 조건에 맞는 배열 리스트 만들기
.sort(ascendingList)
.map(suffixWon)
}
→ .filter .sort .map 을 활용하여 하나의 파이프 라인처럼 보이게 한다. (Queue 처럼 동작하게 보인다.)