Call function based on input parameters javascript

41 Views Asked by At

We have a script that gets input from the cmd (easy trough commander, we are running Node) but once we have this input how can set a array? For example, the input is "doge" and I want to call the Doge element of a dict. I searched and tought window[] could do this, but is not the case for node.

const { program } = require('commander');

program
  .option('-p, --pair <type>', 'pair tocken to farm');

program.parse(process.argv);

const options = program.opts();
if (options.pair) console.log(`- ${options.pair}`);
if (options.pair=='MATIC,BANANA') {
    console.log(options.pair.split(',')[0])
}
const pair = obj[options.pair]
console.log(pair)
var dict = {
  Name: ["Eric","rodrigez"],
  Age:  23,
  Job: "Freelancer",
  Skills : "JavaScript",
  BANANA :"perfect"
};

console.log(dict.pair)
0

There are 0 best solutions below