Javascript如果Else语句与mathFoor和mathRandom不起作用

问题描述 投票:0回答:1

您好,我的代码遇到了一些问题,如果有人能帮助我的话,我对此很新。谢谢。

var a = 5;
var b = 6;
var c = 7;
document.write(Math.floor((Math.random() * 3) + 5));

if (5) {
  alert("mission failed we will get them next time");
} else {
  alert("sorry");
}
javascript webpage
1个回答
0
投票

请从学习文档=> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else开始

let RandomVal =  Math.floor((Math.random() * 3) + 5);
console.log(RandomVal);
if (RandomVal===5) {
  console.log("mission failed we will get them next time");
} else {
  console.log("sorry");
}
© www.soinside.com 2019 - 2024. All rights reserved.