Error in Javascript loop

Asked

Viewed 34 times

0

I am writing a code and, at the time of going through the array, vscode has error in the first line of my is, but I can’t find the error, and I don’t know if it is vscode error either. Code below:

const array = [[09, 13, 19, 24, 29, 46],[07, 15, 24, 41, 48, 50]];

     for(let i = 0; i < array.length; i++){
      for(let j = 0; j < array[i].length; j++){
    
      }
     }

In this case, the error is set to "for (Let i = 0; i < array.length; i++){"

can see some error?

  • Which error appears?

  • Expression expected.

  • The error then is not pq has nothing within the 2° for?

  • I have already placed the argument inside the second for and the error persists. The keyword Let is underlined on this line. I don’t know if there’s anything wrong with the keyword.

  • Man, I put in my Vscode but it shows no error, put to run and it worked

  • Then it must be my msm vscode, I will see if it is updated, if it is not I will reinstall. There is no other alternative. Vlw ;)

  • tries to reinstall the extension

Show 2 more comments

2 answers

0

const array = [[09, 13, 19, 24, 29, 46],[07, 15, 24, 41, 48, 50]]

 for(let i = 0; i < array.length; i++){
  for(let j = 0; j < array[i].length; j++){
    console.log(array[i][j])
  }
 }

I ran the Vscode and it worked normally. It turns on that the Let and the const were born in ES5 or 6, so depending on the line you are using or the extension in Vscode there may be criticism!

0

const array = [[09, 13, 19, 24, 29, 46],[07, 15, 24, 41, 48, 50]]

 for(let i = 0; i < array.length; i++){
  for(let j = 0; j < array[i].length; j++){
    console.log(array[i][j])
  }
 }

As you can see, the program runs perfectly. It must be some error in your Vscode, try to update its extension or search for some other.

I recommend the extension Quokka.js. It serves both javascript and typescript. It executes your code immediately while you type and displays various execution results in your code editor.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.