I've tried fiddling around with the code, this is the closest I've gotten to accomplishing what I want. As of right now it rewrites the index[0], leaves index[1] untouched, and adds index [2]. I'm trying to get it so it leaves both index[0] and index[1] untouched, just adding the new index.
// Store all accounts and information
var account = [
{
username: "John Sant",
password: "dog123",
balance: 450
},
{
username: "Rebecca Dunson",
password: "Munco38",
balance: 1276
}
]
// Create new user or proceed to sign in
var task = prompt("Do you have an account? (Yes or No)")
if(task.toLowerCase() === "no"){
for(i = 0; i <= account.length; i++){
var newUsername = prompt("Enter your first and last name:")
account[i++] = {username: newUsername}
};
}
Just focusing on the username at the moment