I'm still a newbie developer and would really appreciate some help. The below function on() is called from within another function when the user scores 10/10 on a quiz. The username is initially created from a username login on a different page and that value is successfully stored in localStorage. That part is working fine and I can call that value (within the on() function) using the first part of the below statement if I leave out the first 'if' statement line and the entire 'else if' statement. However, I'm trying to cater for the time should the user not enter a username, because when the first part of the on() function is called it displays the following: "Congratulations {null}! You scored the perfect 10". I would prefer it to display the alternate message within the 'else if' section below. Any guidance on what I'm doing wrong would be appreciated.
function on() {
if (localStorage.getItem("users") == true) {
document.getElementById("overlay").style.display = "block";
document.getElementById("overlay").innerText = "Congratulations " +
window.localStorage.getItem('users') + "! You scored the perfect 10!";
} else
if (localStorage.getItem("users") === null) {
document.getElementById("overlay").style.display = "block";
document.getElementById("overlay").innerText = "Congratulations! You scored the perfect 10!";
}