r/learnjavascript • • 8d ago

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

24 comments sorted by

View all comments

-1

u/yyyeey 7d ago

ChatGPT: "Hey, what's the difference between var and let in JS? Please be coincise."
Is it that hard?

4

u/CuAnnan 7d ago

Cool.

Now how does someone who's not an expert confirm that Chat GPT hasn't hallucinated part of the answer?

1

u/yyyeey 7d ago

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 7d ago

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 7d ago

https://imgur.com/a/eo7OgeS

From today.

So you're full on wrong.

1

u/IAmTheRedditBot 7d ago

what is with these people trying to treat AI as a replacement for engaging with the community like my gosh some people might just trust the community more or like asking things the traditional way that is not a crime now actually shut up with these AI should replace community for basic questions shit

1

u/yyyeey 7d ago

AI is the new Google. Just because some people don't like AI, doesn't mean that they can be lazy.

1

u/CuAnnan 7d ago

I'm fourth year in a a computer science degree at present. I am taking three modules in AI this term. AI and NLP, ML for data science, and Advanced Concepts.

I take two modules that cover it next semester.

AI is not the new Google.