Click to See Complete Forum and Search --> : undefined 'objects'


Melons
11-29-2003, 08:23 AM
Related to my previous post on math random arrays :

I have created a basic poem generator which can be seen here Poem Generator (http://www.melswebs.com/generators/nature.htm) . It uses an external JS file (www.melswebs.com/generators/nature.js)

Although I get no error prompts when a new poem is refreshed, for some reason some words/phrases come up as 'undefined.' Presumably the script cannot find a word/phrase to use, although the coding seems to be ok.

Any ideas please?

Best regards,

Mel

96turnerri
11-29-2003, 10:34 AM
i couldnt get undefined to come up, having a look at the coding now

Melons
11-29-2003, 11:26 AM
Thanks ....appreciate it. Maybe I am the only one seeing 'undefined' words appearing??? :rolleyes:

batfink
11-30-2003, 02:45 AM
The reson for the undefined is because each line like this:
+ z3[Math.round(Math.random() * 37)]
calls an index of the array that is too large. (one over)
In the line above for example the 37 needs to be 36
Therefore in each line of your html file for the array you will need to drop the number by one.:)

Melons
11-30-2003, 05:35 AM
:D

Hey thanks BATFINK, your a darlin'

IT works!!!! :)

blowin' ya a kiss.....

psssst ..... any chance you can answer the other question I posted about random math and word arrays.......?

All the best now,

Mel xox