Last active
November 24, 2016 13:34
-
-
Save Marlysson/de8d7b332590f933991e398898231737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.contains = function(valor_desejado){ | |
var quantidade = 0; | |
this.forEach(function(valor_atual,indice){ | |
if (valor_atual === valor_desejado){ | |
quantidade += 1; | |
} | |
}); | |
if (quantidade > 0){ | |
return true; | |
} | |
return false; | |
} | |
let nomes = [ "MARLYSSON" , "MARCELO" , "MARCOS" ] | |
console.log(nomes.contains("MARLYSSON")) | |
// true | |
console.log(nomes.contains("MARCELO")) | |
// true | |
console.log(nomes.contains("TESTE")) | |
//false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment