4 ms·
Source is cute: flip a coin indeed - <script src="http://www.google.com/jsapi"></script> <script> // Load jQuery google.load("jquery", "1
by telemachos 17y ago
Source is cute: flip a coin indeed -
<script src="http://www.google.com/jsapi"></script>
<script>
// Load jQuery
google.load("jquery", "1.4");
google.setOnLoadCallback(function() {
var decision = Math.floor(Math.random()*2)
if (decision == 0) {
var response = "NO";
} else {
var response = "YES";
}
window.setTimeout(function() {
jQuery('#answer').html(response);
}, 2000);
});
</script>
- thaumaturgy 17y agoBah. Code should just be: if (Math.random() < .5) { var response = "NO"; ...
- gb 17y agoor var response = Math.random() < 0.5 ? "NO" : "YES";
- tfe 17y agoImplemented, thanks.
- thaumaturgy 17y agoNice! Or: google.setOnLoadCallback(function() { window.setTimeout(function() { jQuery('#answer').html(Math.random() < 0.5 ? "NO" : "YES"); }, 2000); });