Javascript breadth first search

resource leave min = arr [0]; // defines the minimum value for the first element for (let i = 0; I CR [i]) {min = arr [i]} // if the element I'th lower value perminimation for him} newarr.push (min); // add smaller element to new matrix and reset arr.Splice (arr.indexof (min), 1) return insertions (arr}}}} {return newrr} return findminandremove ... ................
................