JavaScript//Local Storage

Good Afternoon, I’m hoping for some guidance. I am new to JavaScript and struggling with a project. We have been asked to store new entries into a website application, which once added store into the local storage.

This is what I have so far, but I am at a loss where I am going wrong to get this stored.

The first section surrounded by ** works fine (albeit it doesn’t store the entires). It is the last bit where I’m trying to add new code to store the message and invoke the event listener which doesn’t work.

Any guidance would be greatly appreciated.

**function addTextEntry(itemKey, initialText, isNewEntry) {
// Create a text element to edit the entry
var textElement = document.createElement("textarea");
textElement.rows = 5;
textElement.placeholder = "(new entry)";
// Set the textarea's value to the given text (if any)
textElement.value = initialText;
// Add a section to the page containing the textarea
addSection(itemKey, textElement);
// If this is a new entry (added by the user clicking a button)
// move the focus to the textarea to encourage typing
if (isNewEntry) {
    textElement.focus();
}**

// Create an event listener to save the entry when it changes

function saveEntry() {
    // A new version of this function is created every time addTextEntry is called,
    // so it can access all the variables available in this call to addTextEntry
    console.log("saveEntry called with variables in scope:", {
        itemKey,
        initialText,
        isNewEntry,
        textElement,
    });
    
    document.getElementById(initialText);
    item = makeTextItem(initialText); 
    localStorage.setItem(itemKey);  
    textElement.addEventListener("initialText", saveEntry); 
    
}

}