Leetcode Selection Sort In Javascript