aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/math
diff options
context:
space:
mode:
authort7yang <t7yang@gmail.com>2022-01-10 08:38:07 +0800
committerIrvin <irvinfly@gmail.com>2022-02-16 02:35:54 +0800
commit563ca0a35e98678e2b7d5f154f31f496851e8d60 (patch)
tree7c99e7e037128217eca2080df671a742076c615b /files/zh-cn/web/javascript/reference/global_objects/math
parentd7b2995cabe8d85a1827aa18bc270bdf739f3d13 (diff)
downloadtranslated-content-563ca0a35e98678e2b7d5f154f31f496851e8d60.tar.gz
translated-content-563ca0a35e98678e2b7d5f154f31f496851e8d60.tar.bz2
translated-content-563ca0a35e98678e2b7d5f154f31f496851e8d60.zip
remove code tag inside pre tag for zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/math')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/math/random/index.html10
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html4
3 files changed, 9 insertions, 9 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html
index fcfc82fbd5..efc463d5b7 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html
@@ -23,11 +23,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI
<p>下面的函数使用 Math.PI 计算给定半径的圆周长:</p>
-<pre class="brush:js language-js"><code class="language-js">function calculateCircumference (radius) {
+<pre class="brush:js language-js">function calculateCircumference (radius) {
return 2 * Math.PI * radius;
}
-calculateCircumference(1); // 6.283185307179586</code></pre>
+calculateCircumference(1); // 6.283185307179586</pre>
<h2 id="规范">规范</h2>
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 91796ae506..04602b2699 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
@@ -50,11 +50,11 @@ 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"><code class="language-js">function getRandomInt(min, max) {
+<pre class="brush: js line-numbers 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">
-}</code></pre>
+ return Math.floor(Math.random() * (max - min)) + min; //不含最大值,含最小值
+}</pre>
<div class="note">
<p>也许很容易想到用 <code>Math.round()</code> 来实现,但是这会导致你的随机数处于一个不均匀的分布,这可能不符合你的需求。</p>
@@ -64,11 +64,11 @@ 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"><code class="language-js">function getRandomIntInclusive(min, max) {
+<pre class="brush: js line-numbers language-js">function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
-}</code></pre>
+}</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html
index 60808dde44..590089e3c1 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html
@@ -50,12 +50,12 @@ Math.sign(); // NaN
<h2 id="Compatibility" name="Compatibility">Polyfill</h2>
-<pre class="brush: js language-js"><code class="language-js">function sign(x) {
+<pre class="brush: js language-js">function sign(x) {
x = +x ;// convert to a number
if (x === 0 || isNaN(x))
return x;
return x &gt; 0 ? 1 : -1;
-}</code></pre>
+}</pre>
<p> </p>