Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 9:20 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Array question
PostPosted: August 17th, 2007, 3:47 am 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Hi all
If I have an array that has 6 words seprated by commas" like this
myWords = "SNAIL,BEE,CRICKET,ANT,FROG,JUNGLE";
myWords = myWords.split(",");
Now I want if the user put in the input text (myGuess) any of these words he'll have +1 score.


Top
 Profile  
 
 Post subject:
PostPosted: August 17th, 2007, 5:28 am 
Could I suggest that you might get a better response if you posted this in the Advanced forum, which is where scripting is usually covered?

That said, I'm not quite sure just what you are asking :)


Top
   
 
 Post subject:
PostPosted: August 17th, 2007, 12:15 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
You'd want to check your myGuess variable against the answer array.

for (x=0;x<myWords.length;x++){
if (myGuess=myWords[x])
{
alert('You got it right.');
break;
}
else
{
alert('You got it wrong.');
}
}
}

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group