Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JS在数组中显示字符串_Javascript - Fatal编程技术网

Javascript JS在数组中显示字符串

Javascript JS在数组中显示字符串,javascript,Javascript,我已经创建了一个数组 var array1=新数组(“jack”、“kaziu”、“wladek”); var display=Math.floor((Math.random()*array1.length)); console.log(显示)使用计算出的索引为数组编制索引: const array1=新数组(“jack”、“kaziu”、“wladek”); const display=array1[Math.floor(Math.random()*array1.length)]; 控制台

我已经创建了一个数组

var array1=新数组(“jack”、“kaziu”、“wladek”);
var display=Math.floor((Math.random()*array1.length));

console.log(显示)
使用计算出的索引为数组编制索引:

const array1=新数组(“jack”、“kaziu”、“wladek”);
const display=array1[Math.floor(Math.random()*array1.length)];

控制台日志(显示)使用计算出的索引为数组编制索引:

const array1=新数组(“jack”、“kaziu”、“wladek”);
const display=array1[Math.floor(Math.random()*array1.length)];

控制台日志(显示)您的预期输出是什么?您能更具体一点吗?
display
的可能重复和可能重复获取一个随机索引。只需使用
array1[display]
您期望的输出是什么?您能更具体一点吗?
display的可能重复和可能重复获得一个随机索引。只需使用
array1[display]