increment button starting from zero instead of one

I wrote the code to display 0 until the increment button is clicked but it starts from one.

let countEl = document.getElementById("count-el")

let count = 0;

function peopleEntered() {
  count = count + 1;
  countEl.innerText = count;
<div class="countapp">
  <h1>People Entered: </h1>
  <h2 id="count-el">0 </h2>
  <button type="button" id="increment-btn" onclick="peopleEntered()"> INCREMENT </button>
  <script src="index.js">

enter image description here

Read more here:

Content Attribution

This content was originally published by Davinci at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: