diff --git a/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/javascript/samuelArandia.js b/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/javascript/samuelArandia.js new file mode 100644 index 0000000000..a518e92479 --- /dev/null +++ b/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/javascript/samuelArandia.js @@ -0,0 +1,51 @@ +function tennisGame (secuencia) { + let game = ['Love', '15', '30', '40' ] + let player1 = 0; + let player2 = 0; + let error = false; + let finish = false; + + console.log('Comienza el partido'); + for (let i = 0; i < secuencia.length; i++) { + if (secuencia[i] === 'P1') { + player1++; + } else if (secuencia[i] === 'P2') { + player2++; + } else { + error = true; + break; + } + if (player1 >= 3 && player2 >=3) { + if (player1 == player2) { + console.log('Deuce'); + }else if (player1 > player2) { + console.log('Ventaja P1'); + finish = true; + } else if (player1 < player2) { + console.log('Ventaja P2'); + finish = true; + } else { + console.log('Error'); + } + } else if ( player1 <= 3 && player2 <= 3 && !finish) { + console.log(`${game[player1]} - ${game[player2]}`); + } else { + finish = true; + } + + if (finish) { + if (player1 > player2) { + console.log('Ha ganado el P1'); + } else if (player1 < player2) { + console.log('Ha ganado el P2'); + } else { + console.log('Error'); + } + break; + } + } +} +tennisGame(['P1', 'P1', 'P2', 'P2', 'P1', 'P2', 'P1', 'P1']); + + + diff --git "a/Retos/Reto #3 - EL GENERADOR DE CONTRASE\303\221AS [Media]/javascript/samuelArandia.js" "b/Retos/Reto #3 - EL GENERADOR DE CONTRASE\303\221AS [Media]/javascript/samuelArandia.js" new file mode 100644 index 0000000000..7cfeed74a0 --- /dev/null +++ "b/Retos/Reto #3 - EL GENERADOR DE CONTRASE\303\221AS [Media]/javascript/samuelArandia.js" @@ -0,0 +1,37 @@ +function passwordGenerator(length, upper, numbers, symbols) { + + let characters = "abcdefghijklmnopqrstuvwxyz"; + let characterUpper = characters.toUpperCase(); + let numbersCharacters = "0123456789"; + let symbolsCharacters = "!#$%&/()=?¡¿"; + let allCharacters = ""; + let password = ""; + + for (let i = 0; i < length; i++) { + if (upper) { + allCharacters += characters + characterUpper; + } else { + allCharacters += characters; + } + if (numbers) { + allCharacters += numbersCharacters; + } + if (symbols) { + allCharacters += symbolsCharacters; + } + random = Math.floor(Math.random() * allCharacters.length); + password += allCharacters.charAt(random); + } + console.log(password); + return password; +} +passwordGenerator(8); +passwordGenerator(8, true, true, true); +passwordGenerator(10, false, true, true); +passwordGenerator(13, true, true, true); +passwordGenerator(16, true, false, true); +passwordGenerator(20, true, true, true); +passwordGenerator(8, false, false, false); +passwordGenerator(10, true, true, false); +passwordGenerator(14, false, false, true); +