Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js random

// using array and random example
function getTheBill() {
  let names = ["bob", "mike", "matt"];

  let randomFriend = Math.floor(Math.random() * names.length);

  let randomFriendBuyng = names[randomFriend];

  return randomFriendBuyng + " is buying us lunch today!";
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js #random
ADD COMMENT
Topic
Name
2+7 =