alert("Hello, world");
function sayHello(name) {
alert("Hello, " + name);
}
We can also make our own functions.
function sayHello(name, day) {
alert("Hello, " + name + " isn't it a lovely " + day + "?");
}
They can take multiple arguments
function sayHello(name, day) {
var greeting = "Hello, " + name + " isn't it a lovely " + day + "?";
alert(greeting);
}
You can use variables to store data with =
You can use if statements and double-equals to check if something meets a condition.
function sayHello(name, day) {
var greeting = "Hello, " + name + " isn't it a lovely " + day + "?";
if (day == "Sunday") {
greeting = "I'm going back to bed.";
} else if (name == "Barry") {
greeting = "Why hello, President Glassner!";
}
alert(greeting);
}
http://github.com/qrohlf/jsconsole