Hi all ! let changeMe = true; TypeError: Assignment to constant variable


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

JS 2 Variable
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Hi
Here are instruction :
Create a let variable called changeMe and set it equal to the Boolean true.
This is what I put :
let changeMe = true;
TypeError: Assignment to constant variable.
Refused ! What’s wrong please ?
thanks !

```

Replace this line with your code.

<do not remove the three backticks above>

#2

In Javascript you normally use the var =keyword=
like

var myVariable = "the variable now has an associated string Value";
console.log( myVariable );

Reading
==the BOOK==
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
https://stackoverflow.com/questions/21906133/when-should-i-use-let-and-var
https://stackoverflow.com/questions/500431/what-is-the-scope-of-variables-in-javascript
== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html <---JavaScript code-convention
http://javascript.crockford.com/survey.html

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com


#3

You’re right Leonhard ! but …
“In this lesson you will learn about two ways to declare variables: let and const.” Codecademy (JS , Variable 1)

Secondly I ve solved the problem ; it 's because there was a lot of bla bla script before , independant from the current exercice .
But I m going to read the difference between let , const and var !
Thanks a lot for your help Leonhard !
sam


#4

As you just starting
i would suggest that you use the varr =keyword= if you declare a VARIABLE

==========================================
As you start the Browser
you are in the =global= environment,
it is the window environment.
If you then define a var in this environment
like
var test = "this is a test string";
you can get access to its associated Value by using window.test
like
console.log( window.test );
or
console.log( test );

he associated VALUE can be anything from:

•Number
•String
•Boolean
•Symbol
•Object  ◦Function/'Method'
         ◦Array
         ◦Date
         ◦RegExp
         ◦Math
•Null
•Undefined

#5

thanks very much Leonhard !
Do you know a webpage where I can check all that or practice some exercices ?


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.