Initializing variables


In "More variable practice" I wrote following code as suggested
String var myCountry = "India" ;
but it shows wrong message as
"Missing ';' beffore statement"
what does this mean?
please help

Replace this line with your code.


If you want to declare a VARIABLE in Javascript
you use
var myCountry = "India" ;

Please read
== the Book==


Hi @curio132 :smiley:
In addition to what @leonhard.wettengmx.n explained, some languages actually do require for you to put the data type before you initialize a variable. However, in JavaScript
You don't need to define the type before that. It's just

var myExample = "this is an example"

Hope this helps you!


Thanks @leonhard.wettengmx.n and @infinitycoder14 for the explanation...I am glad that now I can ask my queries freely in hopes of getting reply as this was my first query in codecademy....
Thanks for replying....


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