Lab49 interview question

Implement an algorithm in JavaScript.