Hi all
I’m working my way through the “JavaScript & AJAX for Dummies” book and I’ve created what should be a simple script for a 2-dimensional array, but I can’t get it working and have no idea what the problem is.
Hopefully someone can help fix it? Here’s what I’ve got:
<script type=“text/javascript”> cityName = new Array(“Indianapolis”,“New York”,“Tokyo”,“London”); distance = new Array( new Array(0,648,6476,4000), new array(648,0,6760,3470), new array(6476,6760,0,5956), new array(4000,3470,5956,0) ); function GetCity() { var theCity = “”; var cityMenu = “Please choose a city by typing in a number: \n\n”; cityMenu += “0) Indianapolis\n”; cityMenu += “1) New York\n”; cityMenu += “2) Tokyo\n”; cityMenu += “3) London\n”; theCity = prompt(cityMenu); return(theCity); } function main() { var output = “”; var from = GetCity(); var to = GetCity(); var result = distance; output = “The distance from “ + cityName; output += “ to “ + cityName; output += “ is “ + result + “ miles.”; alert (output); } main();</script>