I'm new to this world of vanilla javascript. I've been trying complete some challenges but it seems like I'm unable to find the solution to a challenge.
The task is:"Sort array by object property"
- Write a function that takes an array of objects as an argument
- Sort the array by property b in ascending order
- Return the sorted array
function arraySorter(arr) {
return arr
.map((e) => {
return Object.values(e);
})
.filter((e, i) => {
console.log(e[1]);
return;
});
}
console.log(
arraySorter([
{ a: 1, b: 2 },
{ a: 5, b: 4 },
])
);
Expected output
//expected output: [{a:1,b:2},{a:5,b:4}]
// expected output: [{a:5,b:4},{a:2,b:10}]
function arraySorter(arr){ return }... that returnsundefined... did you forget some code?