I'm making a simple counter with a button. I press the button and it increments, that works correctly. But I'm also trying to create a "Save" feature where you can Save your last count. It's returning with "Cannot set properties of null(setting 'innerText').
let buttonCount = 0
let countEl = document.getElementById("count-el")
let saveEl = document.getElementById("save-el")
function increment() {
buttonCount += 1
countEl.innerText = buttonCount
console.log(buttonCount)
}
function save() {
let countStr = buttonCount + " - "
saveEl.innerText = countStr
}
<title>Passenger Counter</title>
<h1>People Entered:</h1>
<h2 id="count-el">0</h2>
<script src="index.js"></script>
<button id="increment-butn" onclick="increment()">INCREMENT</button>
<button id="save-butn" onclick="save()">SAVE</button>
<p id="save-el">Previous Entries: </p>