首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用mathFoor和mathRandom的Javascript If Else语句不起作用

使用mathFoor和mathRandom的Javascript If Else语句不起作用
EN

Stack Overflow用户
提问于 2019-02-21 09:13:23
回答 1查看 36关注 0票数 0

你好,我有一些问题,我的代码,我是相当新手,如果有人可以帮助我,谢谢。

代码语言:javascript
运行
复制
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");
}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-21 09:26:37

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

代码语言:javascript
运行
复制
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");
}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54797742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档