-2

I have the following code block, that works on every browser except IE 11. Im picking content from a json file based on a select drop down. I have read that IE 11 has no arrow function, how do I re-write this to work in IE 11?

$.getJSON('./AJAX/myfile.json', function(data) {
    var items = [];
    var filter = $('#select').val();
    var countryData = data.filter(el => el.selection === filter);
});

The issue is with the "(el => el.selection === filter);" -> "=>" arrow. Is there an alternative?

Dirty Bird Design
  • 5,333
  • 13
  • 64
  • 121
  • Sorry to offend you T.J. I couldn't find a question / answer that I could understand enough to get to work. I should have added "I have spent 2 hrs on this trying to get similar solutions to work, with no success". – Dirty Bird Design May 30 '18 at 18:53

2 Answers2

0

The arrow function here:

var countryData = data.filter(el => el.selection === filter);

can be re-written as:

var countryData = data.filter( function (el) {
    return el.selection === filter;
});
AndrewL64
  • 15,794
  • 8
  • 47
  • 79
-1
  var countryData = data.filter(function (el) { return el.selection === filter; });
Bryan Dellinger
  • 4,724
  • 7
  • 33
  • 79