Initializing variables


#1


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.


#2

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

Please read
== the Book==
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var


#3

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!


#4

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....


#5

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