aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/math/random
diff options
context:
space:
mode:
authorIrvin <irvinfly@gmail.com>2022-02-16 02:02:49 +0800
committerIrvin <irvinfly@gmail.com>2022-02-16 02:35:54 +0800
commit01b0e12ba27b5069248fd09235e9a7143915ee30 (patch)
tree0e9edf538dc3fa3331e1dbb79239b58186765f86 /files/zh-cn/web/javascript/reference/global_objects/math/random
parent6ca84f1794af830ada9736d7289ce29aabb04ca3 (diff)
downloadtranslated-content-01b0e12ba27b5069248fd09235e9a7143915ee30.tar.gz
translated-content-01b0e12ba27b5069248fd09235e9a7143915ee30.tar.bz2
translated-content-01b0e12ba27b5069248fd09235e9a7143915ee30.zip
remove `notranslate` class in zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/math/random')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/math/random/index.html10
1 files changed, 5 insertions, 5 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html
index e25608ec05..91796ae506 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html
@@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox notranslate"><code>Math.random()</code></pre>
+<pre class="syntaxbox"><code>Math.random()</code></pre>
<h3 id="Parameters" name="Parameters">返回值</h3>
@@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
<h3 id="得到一个大于等于0,小于1之间的随机数">得到一个大于等于0,小于1之间的随机数</h3>
-<pre class="brush: js notranslate">function getRandom() {
+<pre class="brush: js">function getRandom() {
return Math.random();
}</pre>
@@ -41,7 +41,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
<p>这个例子返回了一个在指定值之间的随机数。这个值不小于 <code>min</code>(有可能等于),并且小于(不等于)<code>max</code>。</p>
-<pre class="brush: js notranslate">function getRandomArbitrary(min, max) {
+<pre class="brush: js">function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
</pre>
@@ -50,7 +50,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
<p>这个例子返回了一个在指定值之间的随机整数。这个值不小于 <code>min</code> (如果 <code>min</code> 不是整数,则不小于 <code>min</code> 的向上取整数),且小于(不等于)<code>max</code>。</p>
-<pre class="brush: js line-numbers language-js notranslate"><code class="language-js">function getRandomInt(min, max) {
+<pre class="brush: js line-numbers language-js"><code class="language-js">function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; </code>//不含最大值,含最小值<code class="language-js">
@@ -64,7 +64,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
<p>上一个例子提到的函数 <code>getRandomInt()</code> 结果范围包含了最小值,但不含最大值。如果你的随机结果需要同时包含最小值和最大值,怎么办呢?  <code>getRandomIntInclusive()</code> 函数可以实现。</p>
-<pre class="brush: js line-numbers language-js notranslate"><code class="language-js">function getRandomIntInclusive(min, max) {
+<pre class="brush: js line-numbers language-js"><code class="language-js">function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值