Basic Node and Express - Use the .env File

“process.env.MESSAGE_STYLE” is a dot notation to refer to the enviroment variable “MESSAGE_STYLE” which is a property of the object “process.env”.

“process.env” holds all the values of environment variables as properties of the object, thus you need to refer to the variable with the dot notation “process.env.MESSAGE_STYLE”.
This reference to the variable is only for reading the value “uppercase” in your script.

If you want to declare the variable and store the value “uppercase”, do as follows:
if you are using replit you need to use secret tabs to store this variable.
If running project locally, store it in a “.env” file.
Don’t store the variable by declaring let message=“uppercase”, it doesn’t work for environment variables.

you can view the link provided by the hints here for the answer.

1 Like