所以我所拥有的是http://garrettstelly.com,它在启动时会吐出二十个术语之一。代码很重,我很好。
我打算做一个网站来随机吐出一个名字,问题是我可以有无穷无尽的名字。对于我目前使用的 js,我使用随机滚动甚至 0 到 1 之间的部分来读取名称。这样做的问题是我不能只添加一个短语,我必须一次添加一个块才能使概率相等。
如何制作一个脚本,一次添加一个无限可能?
这是 garrettstelly.com 的 javascript:
var roll = Math.random()
if (roll<0.05)
{document.write('<a href="http://www.facebook.com/abroheem.vonclinxenburg">Bro-Heem</a>');}
else if (roll<0.10)
{document.write('I am too white for my own good');}
else if (roll<0.15)
{document.write('I love the way you paste those stickers.');}
else if (roll<0.20)
{document.write('You probably were not just thinking about Wichita');}
else if (roll<0.25)
{document.write('Yummy, Adhesive!');}
else if (roll<0.30)
{document.write('<a href="http://www.rolex.com/">Rolex</a>');}
else if (roll<0.35)
{document.write('There is a 5% chance that you will see this when you first visit this website.');}
else if (roll<0.40)
{document.write('Making Money.<br>Choppas How We Do Today.');}
else if (roll<0.45)
{document.write('45, get your bills roll em high.');}
else if (roll<0.50)
{document.write('I WILL teach you how to fish');}
else if (roll<0.55)
{document.write('I am a gangsta.');}
else if (roll<0.60)
{document.write('Please get out of my website');}
else if (roll<0.65)
{document.write('<a href="http://www.facebook.com/luke.immel?fref=ts">derriere</a>');}
else if (roll<0.70)
{document.write('I think YOU are a Q T PIE');}
else if (roll<0.75)
{document.write('X=Fries');}
else if (roll<0.80)
{document.write("Idle hands are the Devil's playground.<br>The Devil is smaller than hands.");}
else if (roll<0.85)
{document.write('I am about to be late for class');}
else if (roll<0.90)
{document.write('"Hipster"');}
else if (roll<0.95)
{document.write('I am late for class');}
else
{document.write('Please refrain from drinking the water located within the wishing well, thank you.');}