learning JS, first time using netbeans.My code can compile, but i don't know how to print to the console screen. I've tried the system.out.println function, but that still doesn't work. What am I doing wrong?
EDIT: This question is different because i've never actually seen these functions used before. At all the other programs i've used online, the output was automatic, so to add "console.log()....where do i put it, and how do i make it show the values of the variables like in the text?
2 Answers
That looks like you're confusing Javascript with Java. They're not the same language. NetBeans is a development environment for Java, not Javascript. But to answer your main question, to print to the console in JavaScript, you can use the function console.log() like this.
console.log(text);
In your case, you could write
console.log("Obama is " + obama.age + " years old.");
Use console.log("some text") to print the text
(or)
If you want to print the value stored in the variable then you can give the variable name inside the console.log()
e.g.
var text = "some text"
console.log(text)