Array Names not displaying from user input


#1

Hi, my array is not displaying the user input. I have created a loop to check the input is not 0 and push so that the latest input is displayed in an order.
I can’t see why my user input is not working.

Please see my code:

function start() {
//varibles initiated
//objects are vName and vPet
var vName = “”;
var vPet
//prompts for user input
objects.vName = prompt(“Enter a name”);
objects.vPet = prompt(“Enter the number of Pets”);
//initiate arrMem array
var arrMem=[];
//while loops checks the length of the name and adds the last one
while (vName.length>0&&vPet.length>0) {
var objects={name:vName,pets:vPet};
arrMem.push(objects);
//repeat user input statement in loop
objects.vName = prompt(“Enter a name”);
objects.vPet = prompt(“Enter the number of Pets”);
}
//output of listed names and information
var vOutput = " List of Members" + “
”; vOutput = vOutput.bold();
aLen = arrMem.length;
//create msg varible
var msg = “”;
index = 0;
//for loop to check length of names
for
(var i=0;i<aLen;i++){
index++
msg = msg + “List of Names” + index +":" + " " + arrMem[i].vName + arrMem[i].vPet+"
";

document.getElementById(“output”).innerHTML=vOutput + msg;}
}
window.onload = start;


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.