WHAT'S NEW?
Loading...

Javascript Statment Condition


Tutorial Details





1.if...else
live demo :Di browser

Scripth yang digunakan :
var a = 5;
var b = 3;

if (a < b){
    document.write(a+" is less than "+b);
} else if (a > b){
    document.write(a+" is greater than "+b);
} else {
    document.write(a+" must therefore be equal to "+b);
}

2.switch...break
live demo :Di browser

var country = "USA";

switch (country) {
    case "UK":
        document.write("UK citizens are known for being drunk.");
        break;
    case "USA":
        document.write("USA citizens are known for being dumb.");
        break;
    default:
        document.write("No match for value: "+country);
}


0 komentar:

Post a Comment