Created
April 2, 2021 00:20
-
-
Save fernastereo/a065824d678cb4434a754c130301cc11 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
//Ejercicio 1 | |
const count = (str, char) => { | |
console.log(`Recibidos ${str} y ${char}`); | |
let result = 0; | |
for (let index = 0; index < str.length; index++) { | |
if (char == str[index]) { | |
result++; | |
} | |
} | |
return result; | |
} | |
console.log(count('Hellolllll', 'l')); | |
//Ejercicio 2 | |
const filter = (arr) => { | |
console.log(`Recibido ${arr}`); | |
//Manualmente | |
let result = []; | |
arr.forEach(element => { | |
if (element > 10) { | |
result.push(element); | |
} | |
}); | |
return result; | |
//con Array.filter | |
// return arr.filter((elem) => elem > 10); | |
} | |
const data = [3, 12, 45, 7]; | |
console.log(filter(data)); | |
//Ejercicio 3 | |
const hypotenuse = (a, b) => { | |
//Manualmente | |
const result = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); | |
//Con la funcion hypot de JS | |
// const result = Math.hypot(a, b); | |
return result; | |
} | |
console.log(hypotenuse(10, 13)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment