Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edited english variables/problem.md to provide a little more detail o… #328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

billymoroney1
Copy link

…n the difference between let and const

let example = 'some string'
```

When we declare a variable using `let`, we are able to redefine it. If you want to create a variable that never needs to be changed, **declare** it with the keyword `const`. If you try to redefine a `const` variable, you will see an error.
Copy link
Member

@itzsaga itzsaga Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've struggled with how to explain this succinctly. I'm not sure saying "a variable that never needs to be changed" is accurate and could also confuse people. example:

const array = [];
array.push("hello")

is valid and could be interpreted as the variable changing. However, going into all the specifics would be a lot. 100% open to an update of some kind. Wondering what others might think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could steal this from MDN?

"The value of a constant can't be changed through reassignment (i.e. by using the assignment operator), and it can't be redeclared (i.e. through a variable declaration). However, if a constant is an object or array its properties or items can be updated or removed."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MDN's explanation is better. I am concerned that it is not for beginners, but I believe it is more important not to mislead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants