Hi guys,

I am doing the smallest common multiple - intermediate algo and trying my own implementation which gives me a TypeError for the function filArr(…).

Can someone probably have a look? I am really stuck and want to try the array.filter method.

I would be very grateful, thank you very much

////smallest common multiple

function smallestCommons(arr) {

arr.sort();

var rArr=[];

//Array of multiplies of the higher Array value

for (var i=1;i<20;i++){

rArr.push(arr[1]*i);

}

//function for filter, looks if multiplies of a numb(er) is in array

function filArr(numb){

for (var j=1;j<20;j++){

if(rArr.indexOf(j*numb)!==-1) return true;

}

return false;

}

//loop for all numbers in between original array numbers

var z = arr[1]-1;

while (z>0 && arr[0] !== z){

rArr.filter(filArr(z));

z–;

}

return rArr[0];

}