Smallest Common Multiple Confuse

Tell us what’s happening:
Would anyone pls help me understand why my code fails to work?

Thanks a ton.

Your code so far

function smallestCommons(arr) {
 arr = arr.sort((a, b) => b-a);
for (var i = arr[1]+1; i < arr[0]; i++) {
let product = 1;
for (var j = 0; j < arr.length; j++) {
  while ((arr[0]*product) % arr[j] !==0) {
    product ++;
 return product*arr[0];


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36.

link to challenge: (i am not allowed to share links yet to please delete the white spaces before “learn”, “freecodecamp”, “org” to access the link)
https:// learn. freecodecamp. org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple/

the first thing you need to check is sort(), as [6,1] is returned as [6,1], not as [1,6] as I imagine you would want

After that I don’t know which challenge is it so I dont know.