Solutions of Codility training tasks in JavaScript