Custom search function not working on Android 5.1 and lower

Hello guys,

I am working on an app which has a built in search function. But when I exectute a search on Android 5.1 or lower in an emulator (and also on my Nexus 7 (2012) tablet running Android 5.1) I get an error saying “undefined is not a function” which is at the first line of the iteration through the list in which it has to search. Whyis this not working properly on all Android versions?

Here is my code:


$scope.vacaturesZoeken = function() {

    // Variable is value of search box
    var zoekterm = document.getElementById('search_id').value;

    // Check whether there is a proper search term in the variable	
    if (zoekterm.length === 0 || zoekterm.length === 1) {
        // Variable is null, this will be used to check in the function
        zoekterm = null;

    // Search function
    Vacatures.zoek($scope, zoekterm);


// Defining search function
zoek: function($VacatureZoekLijstscope, zoekterm) {
    // Setting variable for found items to 0
    searched.length = 0;
    // For every item in vacatures
    for (var i = 0; i < vacatures.length; i++) {
        // When the box is checked to only search for location
        if (document.getElementById("locatie_check").checked === true) {
        // Here is where is checked whether the variable is null 
        if (zoekterm === null) {
            return false;
        // When the searchterm is in the location property of an item
        else if (vacatures[i].locatie.toLowerCase().includes(zoekterm.toLowerCase())) {
          // Add item to variable 

Can anybody tell me what is going wrong with using this on Android devices with version 5.1 or lower? Thanks in advance!

Alright, so the problem was that I used .includes(). Somehow this function does not work on Android 5.1 and less.

Now I used .indexOf() !== -1, and that does not give any problems.