Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
I want to take input from the user as object and push it to array that i already created in local storage

I'm having an issue with creating the array in the first place I couldn't push (person) to the array. I changed my code several times because of this error and I tried to define the array inside and outside the function but nothing changed. the error testreg.php:53 Uncaught TypeError: Cannot read properties of null (reading 'push')

Thanks for the help.

        var feedback = document.getElementById("feedback");
        var userArray = JSON.parse(localStorage.getItem("key"));
        var person = {
            name: document.getElementById("nameinput").value, 
            email: document.getElementById("emailinput").value, 
            passowrd: document.getElementById("passwordinput").value };  
        
        
        function checkemail(userArray, email) {
        var i;
        var userArray = JSON.parse(localStorage.getItem("key"));
        let isFound = false;
        if(userArray != undefined) 
        for (i = 0; i < userArray.length; i++) {
        let oldemail = userArray[i].email; 
        let newemail = document.getElementById("emailinput").value;   
        if (newemail === oldemail) { isFound = true; i = userArray.length;          

        return feedback.innerHTML = "email exist please log in or register with different email";
        }}

        if(!isFound) {
        return storeName(person, userArray);
        }}
        

        function storeName(person, userArray){ 
            var person = {
            name: document.getElementById("nameinput").value, 
            email: document.getElementById("emailinput").value, 
            passowrd: document.getElementById("passwordinput").value };
             
        var userArray = JSON.parse(localStorage.getItem("key"));
        userArray.push(person);
        userArray = JSON.stringify(userArray)
        localStorage.setItem("key", userArray);
        console.log(userArray);
                                                    }



        function clearStorage(){
        localStorage.clear();
            
                                                    }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda