Jacob Crofts
Jacob Crofts

Reputation: 186

Why doesn't node run javascript functions in my terminal or browser?

I'm using node.js to run JavaScript in my terminal. When I run the following JavaScript file (testfile.js) in my terminal with the command "node testfile.js", here's what I get:

console.log("meh");

=> meh

So that works fine. But when I make it a function like this:

function sayMeh() {
    console.log("meh");
};

sayMeh;

=> 

I get no result. Why? How can I test JS to see if it works?

Upvotes: 1

Views: 306

Answers (1)

Paul Roub
Paul Roub

Reputation: 36458

You need to call the function, not just mention it.

sayMeh();

Upvotes: 5

Related Questions