📜  js 随机 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:19.351000             🧑  作者: Mango

代码示例6
// 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!";
}