Baffled as to why both console.logs output a sorted array. It's as if both console.log lines are being run at the end of the script. I was expecting the first console.log to output the unsorted array!? If I comment out the sort the array appears unsorted in the initial console output.
const notes=[
{title: '2. My Next Trip',
body: 'I would like to go to Spain...'},
{title: '3. Habits to Work On',
body: 'Exercise. Eating a bit better'},
{title: '1. Office meditation',
body: 'Get a new seat'}
]
console.log(`Unsorted Array : `, notes)
notes.sort((a, b)=>{
if(a.title < b.title) return -1
else if(a.title > b.title) return 1
else return 0
})
console.log(`Sorted Array : `, notes)