vendredi 27 novembre 2020

Check if button has been pressed

I want to add an if statement that checks if the user is undefined for my program. It should alert: "no more profiles". The problem is that my "likeId" is undefined to start with and I will get the alert first time i run the function. I would like to know that I can make an if statement that checks if a certain button has been pressed exactly one time.

This is my code:

if (localStorage.getItem('likeId') == "undefined"){
    alert("no more profiles to swipe")
}

My code should look something like this:

if (localStorage.getItem('likeId') == "undefined" && Button has been clicked exactly one time){
        alert("no more profiles to swipe")
    }

Aucun commentaire:

Enregistrer un commentaire