when binding the function onLoad() to the onload event of the body element, you need to use parenthesis so that the function instantiates:
CODE
<body onload="onLoad()">
the line declaring the variable resault needs to have a trailing semi-colon:
CODE
var resault;
when you are assigning the subject string to be checked in your case expression, you need to use single or double quotes, all strings must be contained in one of these.
CODE
switch(i="two") {
within a switch statement, each case needs to end in a colon. the same is true for the default case
e.g.
CODE
case "three":
Although this appears to be an exercise (so you have assigned referenced the subject string to the variable i within the call to switch() itself) your demonstration of switch's purpose might be clearer if you assign "two" to i before you get to switch():
CODE
function onLoad(){
var i = "two";
var resault
switch(i) {
case 'one':
case 'two':
resault='OK';
break;
case 'three':
resault='OK2';
break;
default:
resault='NONE';
}
document.write(resault);
}
let me know how it goes!
This post has been edited by SoLi: 18 Jun, 2009 - 02:36 PM