I would like to compare the output of dice1()
with the output of dice2()
, I suspect I have to return
the value, however I do not know how to. At the bottom, as comment, there is just the beginning of the conditional I would like to use but the values inside do not reflect what I thought.
function dice1() {
const rdm1 = Math.random()
let m = rdm1 * 6
if (m >= 1) {
let floor = (Math.floor(m) + 1);
console.log("this is dice 1 = " + floor)
} else if (m < 1) {
let ceil = (Math.floor(m) + 1);
console.log("this is dice 1 = " + ceil)
}
}
dice1()
function dice2() {
const rdm2 = (Math.random() * Math.random())
let m = rdm2 * 6
if (m >= 1) {
let floor = (Math.floor(m) + 1);
console.log("this is dice 2 = " + floor)
} else if (m < 1) {
let ceil = (Math.floor(m) + 1);
console.log("this is dice 2 = " + ceil)
}
}
dice2()
//if (dice1() < dice2()) {
//console.log( dice2() + " is bigger than " + dice1());
//}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Dice Game</h1>
<script src="main.js"></script>
</body>
</html>