var products = [
{ id: 0, price: 70000, title: "Blossom Dress" },
{ id: 1, price: 50000, title: "Springfield Shirt" },
{ id: 2, price: 60000, title: "Black Monastery" },
];
$("#sortPrice").click(function(){
products.sort(function(a,b) {
return a.price - b.price ;
})
});
위처럼 제대로 작성했는데 버튼클릭시 어레이 정렬이 안 되네요;;
코드가 잘못되었나 싶어서
console.log(products.sort(function(a,b) {
return a.price - b.price
}))
콘솔로그 해봤는데 잘 되네요;
먼가 엄청 간단한 실수 같은데 이런실수로 헤메는거 정말싫어요....