Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

javascript help with variables

Name: Anonymous 2012-11-03 13:02

With some help, I wrote this javascript.

http://pastebin.com/uSSZp0j6

I don't understand how to add more than one variable to a variable, I need for there to be several "keycodes," not just one. Other than that, the script works fine.

Name: Anonymous 2012-11-03 21:56


var keycodes = new Array("apples", "grapes", "oranges")

x = "incorrect"
for (i = 0; i < keycodes.length; i++)
  if (y == keycodes[i])
    x = "correct"

Name: Anonymous 2012-11-04 23:37

>>7
he is getting a list of things addressable by index - array:
var keycodes = new Array("apples", "grapes", "oranges")
affecting a temporary variable to hold the text
x = "incorrect"
then cycling thru all elements of the above mentioned array; to do this he makes use of a temporary variable i, of value 0, 1, and so on until the length of the array minus 1.
for (i = 0; i < keycodes.length; i++)
at each iteration of the cycle he tests if the code at that position of the array is the same at the one held by the variable y, and if so, affects x
  if (y == keycodes[i])
    x = "correct"

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List