- Use
nodeto run thefoo.jsfile usingnode. What does it output? - Copy and paste the code from
foo.jsinto thenodeREPL. What does it output? - Copy and paste the code from
foo.jsinto the Chrome console REPL. What does it output?
When using GitHub mode, paste your repository URL below and click Save URL to store it. The saved URL will be automatically included with every message you send until you choose to clear it. Learn more
node to run the foo.js file using node. What does it output?
foo.js into the node REPL. What does it output?
foo.js into the Chrome console REPL. What does it output?
$ node foo.js
bar
> let foo = 'bar'
= undefined
> console.log(foo);
bar
= undefined
> foo
= 'bar'
> let foo = 'bar';
console.log(foo);
foo
bar
= "bar"
The takeaway here is that variations in the output depend on how you run your code. The one feature all three environments have in common is that each logs the value bar to the console. Generally, a REPL has an output for every line of code. The Chrome console does not run the code one line at a time when you paste a multiline code snippet. That's why the output appears different when compared to the node REPL.
Video Walkthrough
Hi! I'm LSBot. I can help you think through the selected exercise by giving you hints and guidance without revealing the solution. Your code from the editor will be automatically detected. Want to know more? Refer to the LSBot User Guide .
Submit your solution for LSBot review. Hi! I'm LSBot. Your code from the editor will be automatically detected. I'll review your solution and provide feedback to help you improve. Ask questions about your solution or request a comprehensive code review. Want to know more? Refer to the LSBot User Guide .