Reputation: 1899
I'm a newb getting started with JavaScript. I've been using SublimeText 2 and I was greatly helped in the past by using SublimeREPL to get immediate feedback when i was learning Ruby.
Now that I'm working on JS, I've tried to set it up for Node. I installed Node.js on my computer, and it's working from the command line. (However, I'd strongly prefer using SublimeREPL since I can run whole saved files from the color-coded text editor.) SublimeREPL works pretty well, but I'm getting a strange 'undefined' return for every line. I'm not sure why, and I'd like it to stop.
For example, from this program:
var chhd = "cheese head"
var number = 0
while (number <= 12) {
console.log(number);
number = number + 2;
}
chhd.toUpperCase();
I get this result:
> undefined
> undefined
> ... ... ... 0
2
4
6
8
10
12
14
> 'CHEESE HEAD'
What's going on? Should I be getting all these 'undefined's and elipses? And if not, how can I remove them to get SublimeREPL for Node working properly?
Upvotes: 1
Views: 616
Reputation: 36339
Not sure about the ellipses, but the Node REPL behaves the same way on the 'undefined'. The return value of the line in question (var chhd = "cheese head";
) is in fact undefined when interpreted (insofar as it has no return value, like an equation would have (e.g. 1+2
).
Upvotes: 1