Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChris Utley
9,300 PointsTrouble with using Workspaces console.log function...
I'm currently attempting the Practice Basic Arrays in JavaScript, see snapshot link it'll explain the instructions.
I've copy and pasted the console interactions below, what am I doing wrong?
treehouse:~/workspace$ node 1_create_array.js
treehouse:~/workspace$ console.log(languages.length);
bash: syntax error near unexpected token `languages.length'
treehouse:~/workspace$ console.log()
console.log(languages.length)
bash: syntax error near unexpected token `console.log'
1 Answer
james south
Front End Web Development Techdegree Graduate 33,271 Pointsthe workspace console is a bash or terminal instance, it doesn't know what console.log means. it can run a script file with the node + file_name command as you have done. to run JS not in a file you just need to enter the JS REPL by entering the node
command (by itself, no file name). then you can execute JS statements like console.log. to exit hit Ctrl-C then Ctrl-C again and you will be back in bash.