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
function adyacent(inputArray){ | |
var arr=[]; | |
var res=""; | |
for (i=0;i<inputArray.length-1; i++){ | |
res= inputArray[i]*inputArray[i+1]; | |
operacion.push(res);//añade nuevos elementos y devuelve nueva longitud// | |
} | |
return Math.max(...operacion); | |
} |
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
function palindrome(){ | |
var revWord = ""; //ingresar palabra// | |
var word = +("Ingresa tu palabra:");//convertidor// | |
var cualquiera = word.length; //decifrar longitud// | |
for(var j=cualquiera; j>=0; j--){ //recorrer variable// | |
revWord = revWord+word.charAt(j);//devuelve caracter de una cadena// | |
} | |
if(word == revWord){ //condicionales que permiten con un alert decir si es o no un Palindrome// | |
alert(word+" Es un Palindrome"); |
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
var arr = [1,2,3,4,5,6,7,8,9,10]; //arreglo de 10 numeros// | |
var pares = arr.filter(function(arr){return arr % 2 == 0;//rescatar los numeros que cumplan la condicion// | |
}); | |
console.log(pares); |
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
var arr = [1,2,3,4]; | |
var number = 12; | |
function multiplicar(elemento){ | |
return elemento * number; | |
} | |
console.log(arr.map(multiplicar)); |