劉任昌w3schools物件object
w3schools學習亂數random物件object
Math.floor(變數),floor地板,無條件捨去小數 Math.random產生0到1之間的隨機亂數JavaScriptg數學亂數函數 Math.random()
Math.random() 回傳0 (含) 1 (不含):
利用w3schools的亂數練習
產生以上結果的程式碼
<h2>JavaScriptg數學亂數函數 Math.random()</h2><p>Math.random() 回傳0 (含) 1 (不含):</p>
<p id="demo"></p>
<script>
let x="";/*訂一個空白字串*/
for (let i=0; i< 5; i++)
{
x+= "<br>" + Math.random();
}
document.getElementById("demo").innerHTML = x;
</script>
第二次
JavaScriptg數學亂數函數 Math.random()
輸入要產生的數目Math.random() 回傳0 (含) 1 (不含):
整數31
以上程式碼
<h2>JavaScriptg數學亂數函數 Math.random()</h2>
輸入要產生的數目
<input type="number" id="q" min="1" max="20">
<button onclick="abc()">執行</button>
<p>Math.random() 回傳0 (含) 1 (不含):</p>
<p id="demo"></p>
<h3>整數31</h3>
<p id="demo1"></p>
<script>
function abc(){
let n = document.getElementById("q").value;
let x="";/*訂一個空白字串*/
let y=""
for (let i=0; i< n; i++)
{ let z= Math.random();
x+= "<br>" + z;
y+= "<br>" + Math.floor(z*10);/*產稱0到6*/
}
document.getElementById("demo").innerHTML = x;
document.getElementById("demo1").innerHTML = y;
}
</script>
https://meimei20041026.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://www.blogger.com/blog/post/edit/preview/1173902976928833486/5125504722865425539
回覆刪除作者已經移除這則留言。
回覆刪除https://www.blogger.com/blog/post/edit/preview/4093219027139658850/3584296271469309789
回覆刪除https://hsiao-yu0711.blogspot.com/2023/12/w3schoolobject.html
回覆刪除https://euhffh822.blogspot.com/2023/12/w3schoolobject.html
回覆刪除https://ccp19890604.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://pcai766.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除作者已經移除這則留言。
回覆刪除https://ruubyy0.blogspot.com/2023/12/blog-post.html
回覆刪除https://d11217133.blogspot.com/2023/12/w3schools.html
回覆刪除https://the-dumbest-one.blogspot.com/2023/12/w3schoolobject.html
回覆刪除https://fanyahui.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://willy2005940612.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除作者已經移除這則留言。
回覆刪除https://the-most-beeaut.blogspot.com/2023/12/w3schoolobjec.html
回覆刪除https://earnest-person.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://chyuu126.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除作者已經移除這則留言。
回覆刪除https://kungyuting.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://huilii.blogspot.com/2023/12/htmlcssjavascriptjavapython.html
回覆刪除https://xi-xbox-mmi.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://xuangreat.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://the-most-great.blogspot.com/2023/12/math.html
回覆刪除https://honghikun.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://yiminglinn.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://www.blogger.com/blog/post/edit/preview/141866742300809757/8895358727821952047
回覆刪除https://the-most-great-chenxi.blogspot.com/2023/12/w3schoolsrandomobject-math.html
回覆刪除https://sushshshaq119.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://themostgreatteacher.blogspot.com/2023/12/blog-post.html
回覆刪除https://56788888.blogspot.com/2023/12/w3schoolsobject.html
回覆刪除https://682amber.blogspot.com/2023/12/w3schoolsrandomobject-math.html
回覆刪除https://the-most-great-teather.blogspot.com/2023/12/w3schoolsobject-12-03-2023.html
回覆刪除https://kai2424.blogspot.com/2024/01/htmlcssjavascriptjavapython.html
回覆刪除作者已經移除這則留言。
回覆刪除https://michelle814.blogspot.com/2023/12/w3schoolobject.html
回覆刪除