I am building this tarot program, but I am having trouble with the Boolean statements. I only want to show when TRUE statements are executed, but for some reasons, this program is also executing FALSE statement, and is giving me a blank page which I don't want. Here is a link of my project https://jsfiddle.net/4vsyxj3g/.
Here is what I am trying to accomplished. The Tarot card has about 72 cards, and one card can be in the past,present, or future, but it cannot be duplicated. For example, one card cannot be in the past, or in the present, or in the future, at the same time. The program must select a unique card for the past, present, and future. Anyways, thank you for all the help.
Here is the code:
let a = Math.floor(Math.random() * 3)
let b = Math.floor(Math.random() * 3)
let c = Math.floor(Math.random() * 3)
let x = true
console.log(a + " " + b + " " + c);
if (x)
{
if(a != b && a != c && a != c && b != c)
{
let randomPastCard = document.getElementById("textNamePast")
randomPastCard.textContent = card[a].name
let pastTextCard = document.getElementById("pastText")
pastText.textContent = card[a].past
var img = document.createElement("img");
img.src = card[a].img;
document.getElementById('pastTarotImg').appendChild(img);
let randomPresentCard = document.getElementById("textNamePresent")
randomPresentCard.textContent = card[b].name
let presentTextCard = document.getElementById("presentText")
presentTextCard.textContent = card[b].present
var img = document.createElement("img");
img.src = card[b].img;
document.getElementById('presentTarotImg').appendChild(img);
let randomFutureCard = document.getElementById("textNameFuture")
randomFutureCard.textContent = card[c].name
let futureTextCard = document.getElementById("futureText")
futureTextCard.textContent = card[c].future
var img = document.createElement("img");
img.src = card[c].img;
document.getElementById('futureTarotImg').appendChild(img);
console.log("true1");
x = true
}
<hh class="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">
<title>Document</title>
</head>
<body>
<div id="textNamePast"></div>
<div id="pastText"></div> <br>
<div id="pastTarotImg"></div>
<div id="textNamePresent"></div>
<div id="presentText"></div> <br>
<div id="presentTarotImg"></div>
<div id="textNameFuture"></div>
<div id="futureText"></div> <br>
<div id="futureTarotImg"></div>
<br><br>
<br><br>
<script src="tarot.js"></script>
</body>
</html>
}
else
{
console.log("false");
x = false
}
let x = truealways true.