0

So far this is my code:

function number(numm){ var ones = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']; var result; var numString = num.toString(); if (num === 0){ console.log(ones[0]); return ones[0]; } if (num < 10) { result = ones[num]; console.log(result); return result; } if (numString.length === 2) { result = ones[numString[0]] + ' ' + ones[numString[1]]; console.log(result); return result; } if (numString.length == 3) { if (numString[1] === '0' && numString[2] === '0'){ result = ones[numString[0]] + ' zero zero'; console.log(result); return result; } else{ result = ones[numString[0]] + ones[numString[1]] + ' ' + ones[numString[2]]; console.log(result); return result; } } } 

It prints whatever user inputs into its phonetic value, so when the user inputs 25, it should print TwoFive. However, I can't find anything about setting my node so that when the input is: node main.js 25 it should call my function and print TwoFive. Any pointers as to how to achieve this? Will this work for an array of elements? node main.js 3 25 should print Three, TwoFive

5
  • 1
    This looks very similar to this question: stackoverflow.com/questions/67307195/… Commented Apr 29, 2021 at 16:14
  • @SebastianRichner it is the exact same question. I am just trying it in a different way Commented Apr 29, 2021 at 17:38
  • @KrauzeGodswar, have you tried the code from that answer? It should do exactly what you want. Commented Apr 29, 2021 at 17:57
  • @SebastianRichner Its an assignment and he is probably in my cohort, and it would look bad if I were to copy someone else's solution from here IMO Commented Apr 29, 2021 at 18:00
  • @KrauzeGodswar, for sure, but it shows how to parse the command line arguments and use them. Commented Apr 29, 2021 at 18:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.