The logic is fine and works, the bug was due to checkBtn and clearBtn variable not being initialized, and to do so just add these at the top of your script.js:
const checkBtn = document.getElementById('check-btn')
const clearBtn = document.getElementById('clear-btn')