At the risk of stepping in where I’m not wanted and until @Paul_Wilkins helps you arrive at the correct solution I can point out a couple of errors.
You are checking the style property here:
if (y.style.display === "none") {
The style property only applies to styles that have been set inline like this;
<div style="display:block">test</div>
It does not refer to the display property as set in the stylesheet for which you would need getComputedStyle instead.
If you are only toggling two divs then you don’t need to do any comparisons; just turn one off and the other one on.
e.g.
function myFunction1() {
var x = document.getElementById("myDIV1");
var y = document.getElementById("myDIV2");
x.style.display = "block";
y.style.display = "none";
}
function myFunction2() {
var x = document.getElementById("myDIV1");
var y = document.getElementById("myDIV2");
y.style.display = "block";
x.style.display = "none";
}
I’ll leave it to @Paul_Wilkins to explain why you should not use inline click handlers or use duplicated functions when one would do. It’s also usually better to let CSS handle the display toggles rather than interfering directly with JS. Let JS just add the appropriate class.