JSON Output Mode
NodeJS
Medium
3 views
Problem Description
If --json flag is present, print output as JSON instead of text.
Output Format
Print JSON or text.
Constraints
Use process.argv.includes.
Official Solution
const json = process.argv.includes('--json');
const data = { site: 'meetcode', ok: true };
if (json) console.log(JSON.stringify(data));
else console.log('meetcode ok');
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!