r/learnjavascript • • Oct 19 '26

pretty new

Hey guys, I'm just starting to learn about variables, but I'm finding it hard to understand the difference between var and let.

For example:

let goodDay = true;
console.log(goodDay);

this should print true.

But if we just add this:

let goodDay = true;
console.log(goodDay);
goodDay = false;
console.log(goodDay);

It prints:

true
false

The same goes for var.

However, people say there's a difference; what is it?

0 Upvotes

23 comments sorted by

View all comments

Show parent comment

1

u/yyyeey Oct 19 '26

It's pretty simple - is it 2023? If no, then it's very unlikely that it hallucinated, especially in such trivial matters.

1

u/chikamakaleyley helpful Oct 19 '26

as someone self taught, and experienced, it doesn't always click even if I ask AI to be concise, even if I've given the source in the mdn, etc.

There's a lot of diff ways it could be communicated, and sometimes someone will present it in a way, where it just clicks

You could refine your AI prompt, but often when you're just getting started, you might not really know how to phrase that prompt

1

u/CuAnnan Oct 20 '26

https://imgur.com/a/eo7OgeS

From today.

So you're full on wrong.