'Retrieving data using firebase and javascript

I have a simple game made in javascript that calculates the onclick score and I already linked it to firebase and what I'm trying to do is to make it so if u login to your account ur score will be saved since the last time you played , if u log out score will reset

is there any easy way to make it using only javascript and firebase

here is the code i already have for score counting

       var score = 0;
    function increaseScore(){
        score++;
        count.innerHTML = score;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source