Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!