I saw this a couple of days ago and thought it was finally a solution to this age-old problem!
Who was there first, the chicken or the egg?
JavaScript Chicken or Egg Sort
const array = ['π₯', 'π'];
console.log(array.sort());
// (2) ["π", "π₯"]
There you go, the answer is Chicken
!
But letβs dive deeper and see how this worked out for the egg?
const array2 = ['π', 'π£', 'π€', 'π₯'];
console.log(array2.sort());
// (4) ["π", "π£", "π€", "π₯"]
Hmm weird? Yes, this complicates things.
What are your opinions on this Chicken vs. Egg complication?
View the code on Codepen.
See the Pen Vanilla JavaScript Chicken or Egg? by Chris Bongers (@rebelchris) on CodePen.
Thank you for reading, and letβs connect!
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter