方法 - 把数组元素连接成一个字符串
.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)];