Created
November 17, 2021 17:56
-
-
Save furenku/1c879b90c12bc60dbc02614b41de8bbb to your computer and use it in GitHub Desktop.
métodos de arreglos js
This file contains hidden or 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
| const arreglo = [ 1, 2, 3 ] | |
| arreglo.forEach( | |
| elemento => console.log("un elemento:", elemento ) | |
| ) | |
| const duplicados = arreglo.map( | |
| elemento => elemento * 2 | |
| ) | |
| duplicados.forEach( | |
| elemento => console.log("duplicado:", elemento ) | |
| ) | |
| const elementoDos = arreglo.find(elemento=>elemento == 2) | |
| console.log("elementoDos", elementoDos) | |
| const elementoSiete = arreglo.find(elemento=>elemento==7) | |
| console.log("elementoSiete", elementoSiete) | |
| const menoresA3 = arreglo.filter( e => e < 3 ) | |
| menoresA3.forEach( | |
| elemento => console.log("menor a 3:", elemento ) | |
| ) | |
| const objetosDesordenados = [ | |
| { | |
| valor: 3 | |
| }, | |
| { | |
| valor: 2 | |
| }, | |
| { | |
| valor: 7 | |
| }, | |
| ] | |
| const objetosOrdenados = objetosDesordenados.sort( | |
| (a, b) => a.valor - b.valor | |
| ) | |
| objetosOrdenados.forEach( | |
| elemento => console.log("ordenado:", elemento ) | |
| ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment