Solve this JavaScript interview question in 2 different ways #code # ...

Solve this JavaScript interview question in 2 different ways #code # ...