Made with vanilla JavaScript
Judith Ricketts, Artist, Lecturer and Software engineer - Contact
Commit Date: 26th October 2021
Javascript array methods are arrays forming a data structure containing list of elements which store multiple values in a single variable. The strength of JavaScript arrays lies in the array methods which are built-in functions we can apply to our arrays. Each method has a unique function that performs a change or calculation to our array, saving having to write common functions from scratch.
const ordered = inventors.sort(function(a,b){
if(a.year > b.year) {
return 1;
} else {
return -1;
}
});
console.table(ordered);
const ordered = inventors.sort((a,b) => a.year > b.year ? 1 : -1);
console.table(ordered);
To use arrays to sortcut operations