Style.display = "none" not working!

I’m trying to create a really simple pop-out effect on my portfolio site.

A (simple) summary of the code:

HTML:
image cards

<img id="Cheatsheet" src="./Resources/Cheatsheet.png"/>
<img id="Creditcardchecker" src="./Resources/Creditcardchecker.png"/>

pop-out effect

<div class="overlay"></div>
<img class="overlayImage" id="overlayCheatsheet" src="./Resources/Cheatsheet.png"/>
<img class="overlayImage" id="overlayCreditcardchecker" src="./Resources/Creditcardchecker.png"/>

CSS:

.overlay {
    background-color: grey;
    opacity: 50%;
    position: fixed;
    top: 70px;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 1;
    display: none;
}

.overlayImage {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    max-width: 90%;
    height:auto;
    display: none;
}

Javascript:

let Cheatsheet = document.querySelector('#Cheatsheet');
let Creditcardchecker = document.querySelector('#Creditcardchecker');

Cheatsheet.onclick = function() { 
    document.querySelector('.overlay').style.display = "inline";
    document.querySelector('#overlayCheatsheet').style.display = "inline";
};

Creditcardchecker.onclick = function() { 
    document.querySelector('.overlay').style.display = "inline";
    document.querySelector('#overlayCreditcardchecker').style.display = "inline";
};

document.querySelector('.overlay').onclick = function() {
    document.querySelector('.overlay').style.display = "none";
    document.querySelector('.overlayImage').style.display = "none";
}

This works perfectly for the ‘Cheatsheet’ but not the ‘Creditcardchecker’. The overlay image will pop-up, but will remain once the background overlay is clicked.

Where did it all go wrong??? :sob: