Possible Duplicate:
Copying array by value in javascript
I am a beginner with javascript, so I would really appreciate any help or advice. I'm trying to get the values that I collect with my inputs array (that are put into a form, by the user, in the document) to set them to the words array. So, I would like inputs[0] = words[0]
, inputs[1] = words[1]
etc. I thought by setting words to an empty array, and then to equal the index value of inputs, that I would achieve this, but it's not working. Words keeps showing up as "undefined".
function goMad() {
var words = [];
var inputs = document.getElementsByTagName("input");
for (var i = 0; i < inputs.length - 1; i++) {
inputs[i].value = words;
}
var story = words[0] + "! he said " + words[1] + " as he jumped into his convertible " + words[2] + " and drove off with his " + words[3] + " wife.";
document.getElementById("story").innerHTML = story;
console.log(words[0]);
}