-1

Found and fixed my own error. The problem was that I've had another variable called "map" in a different document, so with that being around my code didn't work. I'll just leave this code here as an example of how to do a map.

<html>
   <head>
   <script type="text/javascript">
      var map = {};
      map["red"] = "not avaliable";
      map["blue"] = "avaliable";

      function car(color){
         this.color = color;
      }
      function initialize(){
         var testCar = new car("blue");

         alert("Value is obviously blue: " + testCar.color);
         if (testCar.color in map) {
            var mappedValue = map[testCar.color];
                console.log("Your car in "+ testCar.color + " is "+ mappedValue);
         } else {
            console.log("No color "+ testCar.color + "in maps");
         }
      }
   </script>
   </head>
   <body onload="initialize()"></body>
</html>
Andy
  • 27
  • 7
  • 3
    You will have to show us what is in the `planes` array. Obviously, it doesn't have the right data in it to satisfy the `if` statement so we'd have to see what's actually in there to help you identify the problem. – jfriend00 Jul 04 '13 at 22:21
  • Just so you realize, `planes.to` would have to contain keys like `"Shanghai"` and `"Washington"`. – jfriend00 Jul 04 '13 at 22:40
  • The problem was on a tottally different place, sorry about that. I had to make a small example, got surprised that it was actually working, and then scan my original code for what's different there. – Andy Jul 05 '13 at 08:13

1 Answers1

0

Problem solved. Be careful you don't have variables with the same name even in different documents.

Andy
  • 27
  • 7