How to iterate through localStorage for different keys with the same value?

Basically I have a table in HTML as schedule with weekdays and input fields for content of each day. Every input has an ID defined and is stored in localStorage. When a new input is added and does already exist in another input of the same day, it adds a class ‘double-input’ to both inputs.
What I’m trying to do now is creating a function that iterates through all localStorage items that are those table contents to find any double inputs and mark them as those by adding the class.

function getAnyDoubleInput() {
    var week;
    if (localStorage.getItem('currentWeek')) {
        week = localStorage.getItem('currentWeek');
    } else {
        week = moment().isoWeek();
    }
    Object.keys(localStorage).forEach((key) => {
        if (key.startsWith(week) && document.getElementById(key.substring(key.indexOf('_') + 1)).className == 'double-input') {
            var keyValue = document.getElementById(key.substring(key.indexOf('_') + 1));
            Object.keys(localStorage).forEach((newkey) => {
                var newkeyValue = document.getElementById(newkey.substring(newkey.indexOf('_') + 1));
                if(newkey.startsWith(week) && newkeyValue.className == 'double-input' && key != newkey) {
                    var weekDays = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag'];
                    weekDays.forEach(day => {
                        if (key.includes(day) && newkey.includes(day)) {

                        }
                    })
                }
            });
        }
    });
}

Short explanation of the keys and input IDs: the IDs are created for example as ‘tdMontag1’, the localStorage key storing this value would be called 40_tdMontag1 (beginning with the week as there are tables for every week).
I’m failing to find a proper way to continue this function (or create a completely new one) in order to add the ‘double-input’ class to all double inputs in the same day and add the ‘no-double-input’ class to inputs that are no doubles.
Any help will be greatly appreciated, thanks in advance.