JavaScript Node.js Basics Building a Command Line Application Capturing Command Line Arguments

users.forEach(getProfile); not working for me

When I start app.js nothing processes. https://w.trhou.se/0yswtgpkx5

3 Answers

Sharina Jones
PRO
Sharina Jones
Pro Student 18,771 Points

I'm on my phone so I can't check, but I think you need to pass the individual users into the function.

Something like

users.forEach(user => { getProfile (user)})
Richard Boothe
Richard Boothe
18,137 Points

@Sharina Jones

That would work if he was using the values within the scope of the JavaScript file, but Quentin needed to use the arguments from the terminal and thus use the command node app.js 'chalkers' 'quintinriley' 'davemcfarland'

I'm to use the process object instead of passing in the individual users

Richard Boothe
Richard Boothe
18,137 Points

Quintin Riley The process object and it's argv method checks the arguments entered on the terminal. So if wanted to get the profiles of "chalkers", "quintinriley", and "davemcfarland", you would need to enter the following command in the terminal: node app.js 'chalkers' 'quintinriley' 'davemcfarland'

The command above will provide you with the necessary arguments. The reason you weren't seeing anything "processed" is because you weren't adding the additional usernames to the command.

Hope this helps, Rich