I tried to generate a random number using Math.random
, but when I looked at the console, the following error occurred and I couldn't.What is the cause?
Thank you for your cooperation.
error message
Uncaught TypeError: Math.ramdom is not a function
[email protected] ml:15
[email protected] ml:9
source code
<script>
function getOmikuji(){
varomikuji=["Okichi", "Nakayoshi", "Koyoshi";
// a-n
// Math.floor(Math.ramdom()*(n+1))
var result=Math.floor(Math.ramdom()*3);
alert(omikuji [result]);
}
</script>
Math.ramdom
is spelled incorrectly. Try modifying it to Math.random
.
This post was posted as a community wiki based on @BLUEPIXY's comments.
© 2024 OneMinuteCode. All rights reserved.