Created
May 30, 2016 15:17
-
-
Save kodamirmo/8ba420c8d7d5805d134e49cc01092333 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
var originales = ['Frase 1', 'Frase 2', 'Frase 3', 'Frase 4']; | |
var frases = ['Frase 1', 'Frase 2', 'Frase 3', 'Frase 4']; | |
var generarAleatorio = function() { | |
var num = Math.random() * (frases.length); | |
return Math.floor(num); | |
} | |
var desplegarTexto = function() { | |
var ponerLetra = function() { | |
if (i < frase.length) { | |
console.log(frase[i]); | |
$('#texto').append(frase[i]); | |
i++; | |
setTimeout(ponerLetra, 200); | |
} else { | |
$('#texto').text(''); | |
desplegarTexto(); | |
} | |
} | |
var index = generarAleatorio(); | |
var frase = frases[index]; | |
var i = 0; | |
console.log('Tamano: ' + frases.length); | |
if (frases.length > 0) { | |
frases.splice(index, 1); | |
setTimeout(ponerLetra, 1000); | |
} else { | |
console.log('.......'); | |
//Copiar el arreglo original en el arreglo frases | |
frases = originales.slice(); | |
desplegarTexto(); | |
} | |
} | |
$(document).ready(function() { | |
console.log(':D'); | |
desplegarTexto(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment