Variables noob question

when writing
script
var lighto = “shinigami”;
lighto “hiiiiiiii”;
alert(“lighto”);

the alert on my weblink does not change, its still saying “shinigami” on the alert instead of “hiiiiiiii”. i tried re-writing, opening from ie to chrome. same thing, i purposely did not put <> on the entry script so that it will let me post to the thread

NVM! noob got it it was a mistake on my end. yup lmao

even though Ivan uses var for variables, you should replace it with let from now on. Here’s a video explaining why var, let and const - What, why and how

3 Likes

I agree with @Lishipu. There are a couple of reasons for this.
One is that var creates variables that are more global and can lead to bugs in your code that can be difficult to find, especially once you start writing programs that become more complex.
Another is that var will not warn you if a variable name has already been taken, so it is easy to overwrite variables without even realising it. These can cause bugs even more difficult to find.
Var is the old, legacy way of declaring variables in Javascript. Let and const are superior updated version.

2 Likes

i appreciate the tips guys. thank you