Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 614 Bytes

js-cli.md

File metadata and controls

35 lines (28 loc) · 614 Bytes

Command Line Interface programs

  1. Write a NodeJS program that produces the sum of its arguments:

    $ node sum-args.js 1 2 3 4
    10
    $ node sum-args.js abra kedavra
    NaN
    
  2. Write a program that draws a triangle like the one below given the height as an argument (using for and then using while):

    $ node triangle.js 5
    *
    **
    ***
    ****
    *****
    
  3. Write a program that receives 2 operands and an operation and produces the result:

    $ node expr.js 15 + 14
    29
    $ node expr.js 2 '*' 3
    6
    $ node expr.js 1234 / 16
    77.125