Created
March 11, 2015 11:57
-
-
Save mindaslab/87bd259a23708eaee786 to your computer and use it in GitHub Desktop.
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
console.log("Hello World!\n"); | |
function sort_by_price(a, b){ | |
return a.price > b.price; | |
} | |
array = [{price: 100}, {price: 50}, {price: 70}]; | |
console.log(array); | |
sorted_array = array.sort(sort_by_price); | |
console.log(sorted_array); | |
first_two = sorted_array.slice(0,2); | |
console.log(first_two); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment