Nested for loops, exercise 5


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-javascript-loops/lessons/loops/exercises/for-loops-iii?action=lesson_resume&course_redirect=introduction-to-javascript

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I do not see what is wrong with my code. Show me the error please.

/home/ccuser/workspace/learn-javascript-loops-L1E5/main.js:5
for (let friendPlacesIndex = 0; friendPlacesIndex < friendPlaces.length, friendPlacesIndex++) {
^
SyntaxError: Unexpected token )
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

let myPlaces = ["Trogir", "Split", "Budva"];
let friendPlaces = ["Sao Paulo", "Trogir", "Tokyo"];
for (let myPlacesIndex = 0; myPlacesIndex < myPlaces.length; myPlacesIndex++) {
  console.log(myPlaces[myPlacesIndex]);
  for (let friendPlacesIndex = 0; friendPlacesIndex < friendPlaces.length, friendPlacesIndex++) {
    console.log(friendPlaces[friendPlacesIndex]);
  }
}

#2

your second loop:

 for (let friendPlacesIndex = 0; friendPlacesIndex < friendPlaces.length, friendPlacesIndex++)

to separate the condition and increment you used a comma (,) this should be a semi-colon (;)


#3

Thank you very much.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.