Selection Sort Problem Leetcode Javascript