2018-10-16 21:32:40 +05:30

11 lines
376 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Generate Random Whole Numbers with JavaScript
localeTitle: 使用JavaScript生成随机整数
---
很高兴我们可以创建随机十进制数,但如果我们生成一个随机整数更有用,它会更有用。
为实现此目的我们可以将随机数乘以10并使用`Math.floor()`将十进制数转换为整数
```
Math.floor(Math.random()*10)
```