Javascript Array filterToUppercase(callback)

Description

Javascript Array filterToUppercase(callback)



var filternames = []
var names = ["Lars", "Jan", "Peter", "Bo", "Frederik"]

var myArray = [];
Array.prototype.filterToUppercase = (function(callback){

    this.forEach(function(element){
        if(callback(element)){
            filternames.push(element.toUpperCase())
        }//from w w w  .  j a  va  2s  . com
    })
    return filternames
})


var filterednames = names.filterToUppercase(function(value){
    return value
})

console.log(filterednames)



PreviousNext

Related