Arguments

Learn and practice how to use arguments with Node, in this lesson.

Since you will be interacting with the CLI, there is a requirement to pass your own input. With Bash, arguments are passed by number and prefixed with a dollar sign.

Note: Since you will not be working with Bash, there is no need to test out the Bash examples. They are used only for demonstration.

Bash vs. Node comparison

Bash example

Before you try this out in Node, see how this would look in Bash. In this example, you will run the Bash script and pass a name to it as an argument. Since this is the first argument, you can access it in the script using $1.

$ bash my-bash-script.sh 'Fred
...