Hello everybody,
It’s my first post. I completed the responsive web certification and am almost done with the javascript one. I have previous experience with C and Phyton (studied Physics at the university).
I have a code that stops working if I use a consol.log(“hello”); in the middle of a for loop. Without the console.log("hello); it works. I would like to understand why. I am not able to figure out why myself. Can someone help me to understand? Thanks
It’s about one of the challenges:
And the code is:
function smallestCommons(arr){
var max = Math.max(arr[0], arr[1]);
var min = Math.min(arr[0], arr[1]);
var mltple = max;
for(var i = max; i >= min; i--){
if(mltple % i !== 0){
mltple += max;
console.log("hello");
i = max;
}
}
console.log(mltple);
return mltple;
}
smallestCommons([23, 18]);