zoukankan      html  css  js  c++  java
  • 基本概念之六

    方法 - 把数组元素连接成一个字符串
    .join() - .join(value) sample .join("*")

    var landmarks = [];
    landmarks.push("My House");
    landmarks.push("Front path");
    landmarks.push("Flikering streetlamp");
    landmarks.push("Leaky fire hydrant");
    landmarks.push("Fire station");
    landmarks.push("Cat Rescue Center");
    landmarks.push("My Old School");
    landmarks.push("My friend's house");

    产生随机数的方法 Math.random();得到0-1之间的一个随机小数
    要产生0-10之间的随机小数,只要Math.random()*10
    要取得一个长度为15的数组的随机索引,只要Math.floor(Math.random()*15)
    Match.floor()只是截取整数部分,不是四舍五入

    var randomWords = ["Explosion","Cave","Princess","Pen"];
    randomWords[Math.floor(Math.random()*4)];

    决策者程序之一

    var phrases = [
    "That sounds good.",
    "Yes, you should definitely do that.",
    "I'm not sure that's a great idea.",
    "Maybe not today?",
    "Computer says no."
    ];
    phrases[Math.floor(Math.random()*5)];

  • 相关阅读:
    vant 移动helloworld
    ts
    study vant
    uniapp 上传图片
    electron
    1
    测试vue模板
    [Java] Spring_1700_Spring_DataSource
    [Java] Spring_1600_AOP_XML
    [Java] Spring_1500_AOP_Annotation
  • 原文地址:https://www.cnblogs.com/balian/p/5968383.html
Copyright © 2011-2022 走看看