Easy javascript

Read environment variable with default

Problem

Read PORT env var or default to 3000.

Hints
  • process.env.PORT || 3000

Your practice code

Ready — edit the code above and click Run.

Solution

const port = process.env.PORT || 3000;
console.log(port);

Try solving on your own first, then reveal the official answer.

Explanation

process.env is how Node reads configuration—12-factor app pattern.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details