Welcome to the Treehouse Community
Looking to learn something new?
when to use var and when not
var message = "hello" alert(message); message = "something" alert(message);
in the third line i didnt have to use var anymore... why? Is the word set as variable once it was used with var or is there something more to it that im missing.
Xavier BassCourses Plus Student 2,246 Points
var message = " " ; (var) is like a box . (message) is the name you give the box. inside that box you can put (or set equal =) anything you want
everytime (var) is used its like creating a new box to store stuff in hope makes sence lol