let
vs const
Use let
when you create a variable where you want to have the option of directly reassigning its value (using =
) somewhere in your code
let message
if (loginSuccessful) {
message = "welcome back!"
} else {
message = "Invalid email or password, please try again"
}
Use const
in all other occasions