Understanding Big O Notation via JavaScript