Why don't the things I learn in codeacademy work outside?


#1

Hello, I'm having a bit of trouble. On my mac there is a built in program called script editor. I decided to copy and paste my own adventure into it. With the simple code:
confirm("Are you ready to play?")
It says it cannot find the variable "confirm".

It also does this with:
var Age = prompt(13)
It says cannot find variable "prompt"
I hope you have an answer. Thanks for reading :smile:


#2

First of all, Javascript is mainly used in websites. So I think these codes like 'prompt' and 'confirm' won't work as you are using an editor. Try something else. Maybe it'll work.:grinning: :smile: :wink:


#3

To run a JavaScript program you use your web browser. You have to link to your .js file from an .html file. When you view the .html file with your browser it runs the .js file.

You make the link like this:

<script type="text/javascript" src="main.js"></script>

Now let's look at that prompt() command.

var Age = prompt(13);

should be more like this:

var Age = prompt("How old are you?");