0

I had installed Node.js to run JS codes that I was doing on LeetCode, but I wasn't able to run the code with it, after that I installed on VS Code the extension named Code Runner, but this is what I've got on the output:

[Running] node "d:\Microsoft VS Code\projects\testing.js"

[Done] exited with code=0 in 0.075 seconds

And here's the code:

function sum(a, b) {return a + b;}

sum(10, 20);

I really don't know why this is happening... :(

7
  • 5
    It worked, but your code doesn't print anything. Commented Jul 10, 2020 at 1:59
  • it did, I called the function sum on the last line, and also if I write console.log("Hello World") it returns the same thing... Commented Jul 10, 2020 at 2:01
  • How about you open a terminal in your code directory and run node testing.js does that work better ? You should see an output to the console if you do `console.log("Hello World") at the end. If you do well, code runner extension is broken maybe. Commented Jul 10, 2020 at 2:05
  • 3
    You called the function—the function doesn’t do anything other than return a value, which you ignore. Commented Jul 10, 2020 at 2:06
  • changed the code to only console.log("Hello World") and ran it on a Windows Terminal using node and it returned nothing, just ran the code and give nothing as output... Commented Jul 10, 2020 at 2:11

1 Answer 1

1

Perhaps it's a bit unrelated but since you mention that you do code challenges I find that quick prototyping, or using scratchpads works great to do lots of changes and see them in real time.

Try REPL or CodeSandbox

Note: I personally use condesandbox for it, you just put the variable that you want in a console.log() and it will print on it's own as you go

Sign up to request clarification or add additional context in comments.

4 Comments

I haven't heard about REPL, going to give it a try, but I just wanted to use VS Code for the challenges because I really enjoy the IDE, and doing everything (notetaking for logic for example) in just one place would be great for me
Oh. there is a great extension that can help you in vsCode for that quokkajs.com
Yes, but that extension doesn't actually run the code right?
mainly shows the return outputs, the console logs and the values that variable holds. As it implies it's for rapid prototyping. For coding challenges I have found that it's more than enough

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.