Created
July 1, 2020 19:46
-
-
Save sienki-jenki/74b0c2404dc52367fd82ba0633413f82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('click', (e) => { | |
const color = getColor(e); | |
document.body.style.backgroundColor = color; | |
}) | |
const getColor = (event) => { | |
const {clientX, clientY} = event; | |
if (clientX % 2 == 0) { | |
return clientY % 2 == 0 ? "red" : "green"; | |
} else { | |
return clientY % 2 == 0 ? "green" : "blue"; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment