Enable Debug Logs With ENV
NodeJS
Medium
3 views
Problem Description
If DEBUG=1, print extra logs around a task.
Output Format
Print logs.
Constraints
Use process.env.DEBUG.
Official Solution
const debug = process.env.DEBUG === '1';
function log(x) { if (debug) console.log('debug: ' + x); }
log('start meetcode');
console.log('task');
log('end');
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!