Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js sort array of objects

const drinks1 = [
	{name: 'lemonade', price: 90}, 
	{name: 'lime', price: 432}, 
	{name: 'peach', price: 23}
];

function sortDrinkByPrice(drinks) {
	return drinks.sort((a, b) => a.price - b.price);
}
Source by flaviocopes.com #
 
PREVIOUS NEXT
Tagged: #js #sort #array #objects
ADD COMMENT
Topic
Name
6+1 =