Console.log() interrupts for loop?

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;
      i = max;
  return mltple;  

smallestCommons([23, 18]);
SyntaxError: unknown: Unexpected character '–'. (7:31)

   5 |   var mltple = max;
   6 |
>  7 |   for (var i = max; i >= min; i–) {
     |                                ^

It is because printing out the hello to the console for each iteration of the for loop slows the script down considerably and FCC only allows a small amount of time before its infinite loop detection throws a message.

1 Like

Thank you very much! It makes sense.