Great software doesn’t just decide what to do when a condition is true, it also has a back-up plan if the condition is false.

<html>
<head>
<style>
img {
height: 300px;
width: 200px;
border: 1px;
border-radius: 10px;
}
div {
margin: auto;
width: 50%;
background-color: black;
height: 300px;
width: 200px;
border: 1px;
border-radius: 10px;
}
button {
width: 200px;
height: 30px;
font-size : 20px;
border-radius: 5px;
margin:0 auto;
display:block;
background-color: #7a88ba;
color: white;
touch-action: manipulation;
}
</style>
</head>
<body>
<div id="imgDiv">

</div><br>
<button onClick="toggle()" id="switch">isOn === false</button>
<script>
var labelOn = "isOn === false";
var labelOff = "isOff === true";
var btn = document.getElementById("switch");
var imgDiv = document.getElementById("imgDiv");
var img = document.createElement("img");
img.src = "https://images.unsplash.com/photo-1537923733628-c28d980ef483?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2734&q=80";

function toggle() {

if (btn.innerHTML === labelOn) {
btn.innerHTML = labelOff;
imgDiv.appendChild(img);
} else {
btn.innerHTML = labelOn;
imgDiv.removeChild(img);
}

}


</script>
</body>
</html>]]>