Coding task written in JavaScript