comp426-2022-spring / comp426-2022-spring/a02

Getting 'undefined' trying to read from command line

Open
#23 2 comments 0 reactions 2 assignees Claimed by @smelliskay View on GitHub
bug help wanted
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

I'm trying to write code that takes in a number from the command line 'npm run flips --number=10'. I am trying to use minimst to read in the number, 10. I ran 'import minimist from 'minimist' and also tried the following, which yields the same issue.
//import { createRequire } from 'module';
//const require = createRequire(import.meta.url);
//const args = require('minimist')(process.argv.slice(2))

I am using the following to read in the number:
let args = minimist(process.argv.slice(2));

let theNum = args['number'];

console.log(theNum);
//just printing the number to see if i can read it in correctly.

When I run 'npm run flips --number=10', the terminal prints 'undefined' in the console instead of the number.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.