Random string

Quick javascript thrown together. It randomizes text elements from an array on each refresh.

I thought about making a base, XML for example, for the text to be pulled from so updating is even easier. Right now it’s more effort than I want to put into this project.

If you want to use the code on your own, here it is (Right click – View source).

<script type=”text/javascript”>
var r_text = new Array ();
r_text[0] = “Rainbows and unicorns”;
r_text[1] = “It’s dangerous to go alone! Take this”;
r_text[2] = “But our princess is in another castle!”;
var i = Math.floor(r_text.length * Math.random()); //Multiplies the length of r_text array by random
document.write(‘<span style=”font-weight:bold;”>’ + r_text[i] + ‘</span>’); //This echoes the r_text variable, being a span it accepts styling