Home > Mobile >  How to add point to an existing score value that works after refreshing the bowser
How to add point to an existing score value that works after refreshing the bowser

Time:10-19

I have an issue with adding a point to the existing/old score value after I refresh the web page. Instead of adding a point to the existing/old score, it replaces it, which means if there's an existing/old score already, it will reset and start from 1 again. I don't want that. I want it continues.

Here's my current code, the localStorage code is on the bottom:

function addPhoto(data, mode) {
    // DATA
    let userName = data.uniqueId;
    let userAvatar = data.profilePictureUrl;
    let word = ['Nice going','That’s better than ever','That’s first class work','I’m impressed','Nothing can stop you now','Well done','Good job','You did it','That’s the way','You rock','I knew you could do it','Keep up the good work','That’s clever','Way to go','Outstanding','Tremendous','Fantastic','You are amazing','No one can beat you','You are the chosen one'];
    let words = word[Math.floor(Math.random()*word.length)];

    if (mode == "winner") {
    wins[userName] = wins[userName] || 0
    wins[userName]  
        addContent(
                `<div style="text-align:center;font-size: .8rem;">
                    <div style='padding-bottom:.25rem;color:#1881FF;'>           
  • Related