Created
December 18, 2016 12:34
-
-
Save kuznetsovandrey76/d81d8f758d0cdc4d7c1f21f07113fb0a to your computer and use it in GitHub Desktop.
without repeats
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 text = document.getElementById('text'); // <div id="text"></div> | |
var quotes = '["1", "2", "3"]'; // any array (JSON or not JSON) | |
quotes = JSON.parse(quotes); | |
text.onclick = function foo() { | |
var random = parseInt(Math.random()*quotes.length); | |
var quote = quotes[random]; | |
if(text.innerHTML == quote) { | |
return foo(); // start the function again | |
} | |
text.innerHTML = quote; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment