我试图让功能在两张图片之间随机选择,但没有任何反应

I'm trying to make function randomly choose between the 2 images but nothing happens

编码程序中上传了2张图片

Function getFoto() {
  var Foto = new Array();
Foto[0] = "image1.jpg";
Foto[1]=  "image2.jpg";

var Nummer =  Math.floor(Math.random()*Foto.length);
  return document.getElementById("result").innerHTML = '<img src="'+Foto[Nummer]+'" />';}   
getFoto()

与编程中的所有事情一样,学习调试本质上是解决大多数问题所需的主要技能。所以在这种情况下,我会首先在 vscode 中设置调试,然后查看您在 math.Floor 函数中传递的值。然后看Nummer的值。然后确保 Foto[Nummer 的值] 有效。

你给Function设置function关键字,JS不会执行和解析

function getFoto() {
  var Foto = new Array();
Foto[0] = "image1.jpg";
Foto[1]=  "image2.jpg";
   
var Nummer =  Math.floor(Math.random()*Foto.length);
console.log(Nummer)
  return document.getElementById("result").innerHTML = '<img src="'+Foto[Nummer]+'" />';
  }   
getFoto()
<div id=result></div>