ok i've got ti to work but still unsure about correct way of returning and using arrays from a function.. heres what i changed.
Code:
<html>
<head>
<title>Univeristy Arrays</title>
<script language="javascript">
function uni(name,city,studNum) {
this.name = name;
this.city = city;
this.studNum = studNum;
}
function initialise() {
var University = new Array();
University[0] = new uni("Victoria Univeristy","Wellington","16000");
University[1] = new uni("University of Canterbury","Christchurch","12500");
University[2] = new uni("Otago Univeristy","Dunedin","17000");
University[3] = new uni("Auckland Univeristy","Auckland","26000");
return University;
}
function display(thisArray) {
for (var i=0; i < thisArray.length; i++) {
document.write("Name: "+thisArray[i].name+"<br>");
document.write("City: "+thisArray[i].city+"<br>");
document.write("Enrollment: "+thisArray[i].studNum+"<br><br>");
}
}
</script>
</head>
<body>
<script language="javascript">
var x;
x = initialise();
display(x);
</script>
</body>
</html>
Is this a good/correct way to catch a return from an array and use it? I've only been learning to program for a few months now.. is it the similar in any other language to do what i am doing?