Getting Started with Deno — Hands On

Command Line Flags Solution


Here's one solution for this assignment:

// command-line-flags.ts
const { args } = Deno;
import { parse } from '';
const parsedArgs = parse(args);

const name = || 'Friend';

console.log(`Welcome, ${name}`);

Here's the result of running the command with and without a flag:

deno run command-line-flags.ts --name Preston
Welcome, Preston

deno run command-line-flags.ts
Welcome, Friend

I finished! On to the next chapter