-
Javascript question
Ok heres what i got, i am getting an error 'cannot assign to a function result' whenever i run this function .. I am gonna post only the first half of the code cuz it is kind of long ,
Code:
sofar="______";
thepot="";
s="";
p="";
theword="";
l=0;
function HangMan() {
theword="daniel";
l=theword.length
if (sofar=theword) {
Finish();
}
userin= prompt('Guess a lettter');
//The For Loop is where it says its happening i have never
// seen this error before so i dont know what it means
for (x = 1; x < l; i++) {
if (theword.substring(x,1)=userin) {
sofar+=theword.substring(x,1);
RefVar();
}
}
If anyone could help i would greatly appreciate it..
oOblackorbOo
-
I think it is your "=" signs. "=" by itself is used to set something to something else. What you want is "==".
so it would look like this on the if statements.
Code:
if (theword.substring(x,1)==userin)
-
Now i am getting 'Object Expected' at this line of code
Code:
userin=prompt('Guess a lettter');
I fix one thing then its on to another!
-
Actually I think your error is occuring at the start of the For loop.
for (x = 1; x < l; i++)
The i++ should be x++
Try this instead and let me know if you need anything else:
for (x = 1; x < l; x++)
-
now i am getting the first error again at
if (theword.substring(x,1)==userin) {
Well at least thats where IE Says it is
Dang IT!
-
it looks like its only happening when i type in the letter 'a'