Storing time from different levels: js

Hi everyone.
I’m developing a digital escape room but I’m struggling to store time from one level to another (I need the time from level 1 to be stored so when level 2 starts, it has the time from level 1 registered in the screen (in this format ‘hours: minutes: seconds’) instead of starting with 0:0:0. The same from level 2 and 3. I need the time from level 1 plus 2 to be stored so that when level 3 starts it should appear the sum up of both levels instead of starting all over again.

Can anyone help?

Here’s my js code:

window.onload = () => {
let hour;
let minute;
let seconds;
let totalSeconds = 0;
let score = 0;

let intervalId = null;

intervalId = setInterval(startTimer, 1000);

function startTimer() {
    ++totalSeconds;
    hour = Math.floor(totalSeconds / 3600);
    minute = Math.floor((totalSeconds - hour * 3600) / 60);
    seconds = totalSeconds - (hour * 3600 + minute * 60);

    document.getElementById("hour").innerHTML = hour;
    document.getElementById("minute").innerHTML = minute;
    document.getElementById("seconds").innerHTML = seconds;

if (document.getElementById(“menu”)) {
localStorage.setItem(“totalSeconds”);

if (document.getElementById("hour")){
    console.log("HORAS OK");
    document.getElementById('hour').innerHTML = parseInt(localStorage.getItem("totalSeconds"))
    }

if (document.getElementById("minute")){
    console.log("MINUTOS OK");
    document.getElementById('minute').innerHTML = parseInt(localStorage.getItem("totalSeconds"))
    }

if (document.getElementById("seconds")){
    console.log("SEGUNDOS OK");
    document.getElementById('seconds').innerHTML = parseInt(localStorage.getItem("totalSeconds"))
    }

}
}

}