I'm trying to create a filter system which allows a user to enter a price, so only festivals in the array which have a lower price will be alerted. However instead the program displays all of the festivals. Thanks for any replies.
Code:
var festivals = [
   ["Reading", "Richfield Avenue", 205, "24th - 26th August", "Rock"],
   ["Park Life", "Manchester", 140, "8th - 9th June", "Dance"],
   ["Glastonbury", "Somerset", 250, "23rd - 25th June", "Alternative"]
];
var filterfestivals = [[]];
var maxuserprice = document.getElementById("maxprice").value;
function filter() {
  for (var i = 0; i < festivals.length; i++)
    if (maxuserprice < festivals[i][2]) {
      filterfestivals.push(festivals[i])
      alert(filterfestivals)
      //i = i + 1
    }
}<p1> Please enter your maximum spending price </p1>
<input id="maxprice"> </input>
<button onclick="filter()"> Filter </button> 
     
     
     
    