Last active
June 26, 2019 02:34
-
-
Save pajaro5/116dc5e5f590823571a340b933cd5788 to your computer and use it in GitHub Desktop.
ejemplo de repetidor ascendente
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
<!DOCTYPE html> | |
<html lang="es"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Recursividad ejemplo arriba</title> | |
</head> | |
<body> | |
<h1>Ejemplo ascendente de recursividad</h1> | |
</body> | |
<script> | |
//Ejemplo que imprime en la consola los números en forma ascendente hasta el máximo ingresado por el usuario. | |
var numeroMaximo = parseInt(prompt("Oye ingresa un número: ")); //4 | |
//var contador = 1; | |
var repetidor = function(contador) { | |
if (contador > numeroMaximo) { | |
console.log('fin'); | |
} else { | |
//logica de negocio | |
console.log('contador: ' + contador); | |
return repetidor(contador+1); | |
} | |
} | |
repetidor(1); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment