Struggling to create a dynamic JSON array that stores name, email ID, and password of users every time someone signs up? I managed to do it for one user, but now I'm stuck trying to create a loop and push elements into the array. Any advice on how to accomplish this?
var users = [];
document.getElementById("sub").addEventListener("click",function store(){
var newUser = {};
newUser.name = document.getElementById("nme").value;
newUser.emailId = document.getElementById("mail").value;
newUser.password = document.getElementById("pd").value;
users.push(newUser);
console.log("user", users);
});