Tell us what’s happening:
Hello Everyone,
I’m stuck with this challenge, I can’t get any clear ideas how should I proceed with the challenge. Could you please guide me with ideas how I should solve this?
I don’t want to copy and paste solutions from other people as that way I won’t be learning anything.
Currently the only thing I’ve done is to get the range of numbers that should be checked, after that I don’t know how I should progress.
I really would appreciate any help!
Thanks!
Your code so far
function smallestCommons(arr) {
//Sort the arr variable
let sortArr = arr.sort();
//Create the variables, and assign value to them
let firstIndex = sortArr[0];
let secondIndex = sortArr[1];
let numArr = [];
//Get the range between the two numbers
for(let i = firstIndex; i <= secondIndex; i++){
numArr.push(i);
}
//Check if the highest number inside the array can be divided with the other items
console.log(numArr);
return arr;
}
smallestCommons([1,5]);
//smallestCommons([23, 18]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
.
Challenge: Smallest Common Multiple
Link to the challenge: