Big O Notation & Time Complexity in JavaScript