Different result in RunJS

Hi everyone, I’m Khalid.
This code in the quiz of the loops section logs the results in this sequence:

‘c123a123t123’, which is reasonable.

This is the code:

const animal = 'cat';
 
for (let i = 0; i < animal.length; i++) {
  console.log(animal[i]);
  for (let j = 1; j < 4; j++) {
    console.log(j);
  }
}

While in the RunJs program it logs in this sequence: ‘cat123123123’

And the output exactly is this:

Any Idea about the cause of this? thank you.

1 Like

Hallo Khalid,

thank you for letting me discover RunJS. I download the software and I tried the code of the exercise with a modification. I post here my result.

I created an array animalArray and I let the loop ‘push’ the values of the counter variables of the loops in the array and then I printed the array. The array has the correct elements in it but it’s still weird the way RunJS prints the single values to the console. I guess it has to do with RunJS, the program and not with JavaScript in itself.

A good question to ask in the forum of RunJS, if they have one.

2 Likes

Hi @stefano, thank you very much!

I just opened an issue on github:

1 Like