Difficulty converting an Array of strings toLowerCase and adding to my function. Javascript

Easiest way is to JOIN the mixed-case array into a string, lowercase it, then SPLIT the string back into an array.

Examples:

var tmp = mcArray.join('~').toLowerCase()
var lcArray = tmp.split('~')

You will need to convert the elements of the array to lower case, not the Array object itself. I don't know exactly what happens inside your function, but something like this:

for(var i = 0; i < arrayName.length; i++) {
    if(arrayName[i].toLowerCase() === "whatever") {
        //Found a match!
    }
}

Post some more of your code and it will be easier to provide a more precise solution! Here's an example of the above.


You can't use toLowerCase() on an array, unless you extend it.

Put this somewhere in your code, then from here on out, you can use it on arrays (note, only if your array is filled with strings)

Array.prototype.toLowerCase = function() { 
    for (var i = 0; i < this.length; i++) {
        this[i] = this[i].toString().toLowerCase(); 
    }
}