Loop Through an Array

Check if your city is one of the cleanest cities.

Code Example

 <script>
  var cityToCheck = prompt("Enter your city name to find out if it's on the Cleanest Cities list", "Honolulu");
  var cleanestCities = ["Cheyenne", "Santa Fe", "Tucson", "Great Falls", "Honolulu"];

  var numElements = cleanestCities.length;
  var matchFound = false;

    for (var i = 0; i < numElements; i++) {
	  if (cityToCheck === cleanestCities[i]) {
	    matchFound = true;
		alert("It's one of the cleanest cities");
	  	break;
      }
    }

   if (matchFound === false) {
	 alert("It's not on the list");

   }
  </script>