So we can modify variable values, but can we reassign variables to different data types? Like changing a variable with a string to a variable with a number or vice-versa?

Question

So we can modify variable values, but can we reassign variables to different data types? Like changing a variable with a string to a variable with a number or vice-versa?

Answer

Yes, you can. Remember, you cannot reassign variables that were defined as a const, but you can reassign variables that were defined with a let. So long as you do this, you can reassign variables to whatever data types you want, regardless of what you initially defined the variable as. Example:
javascript // Here we define a number x. let x = 10; // Here we reassign x to a string. Note that you do not say 'let' again. x = "Hello World"; // Returns "Hello World". console.log(x);

So when reassigning a previously assigned variable, using “let”, you are not able to re-state the “let” statement a second time?
I keep getting an error code thrown back at me for trying to reassign using “let” again.
ex.
let x = 1
let x = 2
(throws error)

let x = 1
x = 2
(result x = 2)