See This Hashnode Article for the logic behind this example.

👍