Complete the code to access the environment variable named PORT.
const port = process.env.[1];The environment variable names are case-sensitive and usually uppercase. To get the PORT value, use process.env.PORT.
Complete the code to provide a default value of 3000 if the PORT environment variable is not set.
const port = process.env.PORT || [1];If process.env.PORT is undefined or empty, the code uses 3000 as a default port number.
Fix the error in accessing the environment variable named DATABASE_URL.
const dbUrl = process.[1].DATABASE_URL;The correct property is process.env all lowercase. Using uppercase or other variations causes errors.
Fill both blanks to safely read the environment variable API_KEY or use 'defaultKey' if not set.
const apiKey = process.env.[1] || [2];
Use process.env.API_KEY to get the variable and fallback to the string "defaultKey" if it's missing.
Fill all three blanks to create an object with keys as environment variable names and values as their values, filtering only variables starting with 'APP_'.
const appEnv = Object.fromEntries(Object.entries(process.env).filter(([[1]]) => [2].startsWith([3])));
We destructure entries into key and value. Then filter keys starting with "APP_". This creates an object with only those environment variables.