TyranoBuilder 1.7---Get Random From Array Using JS

1 min read
8oni's avatar
By 8oni
2 Favourites
0 Comments
774 Views
Hi

Watch video tutorial here :


Just really simple ways to use Java Script to get random text from array.
Here is full code :
var myArray = [
  "Bob",
  "Killua",
  "Gon",
  "Phoebe",
  "Amy",
  "Maya",
  "Akira"
];

var randomItem = myArray[Math.floor(Math.random()*myArray.length)];

[loadjs storage="fruit.js"]
[eval exp="f.randomfruit=randomItem"]
#8oni
Hi [emb exp="f.randomfruit"]! It's nice to meet you!


Documentation :
css-tricks.com/snippets/javasc…
tyranobuilder.com/tyranoscript…
Published:
© 2018 - 2020 8oni
Comments0
anonymous's avatar
Join the community to add your comment. Already a deviant? Log In