I have a simple button that when clicked, the text on the button will change using a event listener. However, I want to add some logic to the code so that when I click it again it just goes back to the original text. I am fairly new to javascript and trying to advance my skills.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Event Listeners JS</title>
</head>
<body>
<button>Click Me</button>
<script>
document.querySelector("button").addEventListener("click", (e) => {
e.target.textContent = "I was clicked"; //Changes click me to I was
});
</script>
</body>
</html>