I have created the below code to add my txt value to localStorage. I am able to add the value with this code but there is bit more requirement for me. I need to get different values of txt1 as different elements in local storage string. With this code I just get only one element in localStorage saying length1 (doesn't matte rhow long the txt1 is. Can anyone help me to solve the problem that how can I change the length of localstorage using txt1 values.
let btn1= document.getElementById("btn1");
btn1.addEventListener("click",function(e){
let txt1= document.getElementById("txt1").value;
let notes=localStorage.getItem("notes").value;
const notesObj={txt1:txt1}
window.localStorage.setItem("notes",JSON.stringify(notesObj));