Pyrius
07-14-2011, 02:01 PM
Whenever I try to compile a script I wrote, I get the error, "class, interface, or enum expected" and it points to a spot in my script that I don't think should create an error... I've tried changing different things in the line it points to, but it doesn't help. Here's are some of the errors:
Code:
var it = 0;
var udt = new array(10);
for(it = 0, it < udt.length, it++){
switch(it){
case 0: udt[it] = prompt("Type a name", "");
case 1: udt[it] = prompt("Type a verb", "");
case 2: udt[it] = prompt("Type an adverb", "");
//case 3: udt[it] = prompt("Type a
//case 4: udt[it] = prompt("Type a
//case 5: udt[it] = prompt("Type a
//case 6: udt[it] = prompt("Type a
//case 7: udt[it] = prompt("Type a
//case 8: udt[it] = prompt("Type a
//case 9: udt[it] = prompt("Type a
//case 10: udt[it] = prompt("Type a
}
}
document.write(udt[0] + udt[1] + "away as" + udt[2]);
Errors:
story.java:1: class, interface, or enum expected
var it = 0;
^
story.java:2: class, interface, or enum expected
var udt = new array(10);
^
story.java:4: class, interface, or enum expected
for(it = 0, it < udt.length, it++){
^
story.java:17: class, interface, or enum expected
}
^
I've looked over the first one and I have no idea why that is an error. If the reason is obvious to you, please be polite. I've only been using javascript for about 2 days.
Code:
var it = 0;
var udt = new array(10);
for(it = 0, it < udt.length, it++){
switch(it){
case 0: udt[it] = prompt("Type a name", "");
case 1: udt[it] = prompt("Type a verb", "");
case 2: udt[it] = prompt("Type an adverb", "");
//case 3: udt[it] = prompt("Type a
//case 4: udt[it] = prompt("Type a
//case 5: udt[it] = prompt("Type a
//case 6: udt[it] = prompt("Type a
//case 7: udt[it] = prompt("Type a
//case 8: udt[it] = prompt("Type a
//case 9: udt[it] = prompt("Type a
//case 10: udt[it] = prompt("Type a
}
}
document.write(udt[0] + udt[1] + "away as" + udt[2]);
Errors:
story.java:1: class, interface, or enum expected
var it = 0;
^
story.java:2: class, interface, or enum expected
var udt = new array(10);
^
story.java:4: class, interface, or enum expected
for(it = 0, it < udt.length, it++){
^
story.java:17: class, interface, or enum expected
}
^
I've looked over the first one and I have no idea why that is an error. If the reason is obvious to you, please be polite. I've only been using javascript for about 2 days.