8. When to 'while' and when to 'for'


#1
  1. When to 'while' and when to 'for'

Hey guys, keep getting an SyntaxError: Unexpected token Error. Any ideas why?

var aBC = ["a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z"]
aBC.toUpperCase()

for (counter = 0; counter < aBC.length; counter++){
    console.log("This is letter \" " + aBC[counter] + " \" of the English Alphabet.")
}

#2

Syntax:

Syntax:

var arrayName = [item1, item2, ...];
   
// next problem is here:
for (var counter = 0; counter < aBC.length; counter++){
    console.log("This is letter \" + aBC[counter] + " \ of the English Alphabet."); 
}

counter was not declared, so you need to use var keyword. lso you hve syntx errors in console.log.


#3

ahh, I see! Thank you! My array items were separated by semi-colons instead of commas and I forgot to declare counts
!


#4

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