Log in

View Full Version : Javascript won't run?


Silicate Wielder
November 29th, 2012, 08:13 PM
Okay, I'm new to JS and I want to know how I can get this code to run using the command prompt as a console.

I'm using Codecademy to learn how to program in java, if that helps any.


//The program starts here.
var opsys = (prompt("What is your operating system?"));
var year = (prompt("Please enter the current year"));
if (opsys === "Windows");
{
console.log("You are running Windows");

}
if (opsys === "Linux");
{
console.log("You are running Linux");

}
if (opsys === "Mac");
{
console.log("You are running Macintosh");

}
console.log(year);

Please correct any errors if you find any.

TheMatrix
November 30th, 2012, 01:12 AM
Um, I think you don't understand what JavaScript is. JavaScript interacts with the browser.
To see the output of your script, head on over to the place where you saved your page in Firefox, and press Ctrl+Shift+K. You might have a different shortcut for different platforms.

Silicate Wielder
November 30th, 2012, 08:02 PM
Um, I think you don't understand what JavaScript is. JavaScript interacts with the browser.
To see the output of your script, head on over to the place where you saved your page in Firefox, and press Ctrl+Shift+K. You might have a different shortcut for different platforms.

I misread the tutorial name, my bad. yeah, I understand what happened now, also do I replace 'console' with something else?

TheMatrix
November 30th, 2012, 08:08 PM
I misread the tutorial name, my bad. yeah, I understand what happened now, also do I replace 'console' with something else?

You could replace it with document.writeln to start.

Silicate Wielder
December 1st, 2012, 12:08 PM
Thanks, I'll try that.