@adiga is correct. Here is an alternate approach using Object Model which is scalable in case you want to add more profiles later on. This will avoid having to always keep adding the old data when you want to update the list of profiles. You can try the below code in CodePen
//creating an OBJECT MODEL by the name Profile
class Profile {
constructor(name, age, gender, address) {
this.name = name;
this.age = age;
this.gender = gender;
this.address = address;
}
}
//creating an array to STORE all profiles
const PROFILELIST = [];
//function to create profiles in BACTH
const createBatchProfiles = (data) => {
data.map(profile=> {
const newProfile = new Profile(...profile);
PROFILELIST.push(newProfile);
});
};
//function to create SINGLE profile
const createSingleProfile = (name, age, gender, address) => {
const newProfile = new Profile(name, age, gender, address);
PROFILELIST.push(newProfile);
};
//Creating new MULTIPLE Profiles in a batch
const newData = [
['Amit Rastogi', 26, 'Male', 'Delhi'],
['Sorya Morya', 24, 'Male', 'Rohtak'],
['Ramya Sharma', 24, 'Female', 'Delhi']
];
createBatchProfiles(newData);
//creating a SINGLE new Profile
createSingleProfile('Neeraj Verma',23,'Male','Noida');
//Output the list in console
console.log(PROFILELIST);
//Creating even more Profiles
const newerData = [
["Himesh Gupta", 25, "Male", "Delhi"],
["Himani Rathore", 31, "Female", "Mumbai"],
["Prakash Sharma", 20, "Male", "Jaipur"],
["Anuradha Basu", 29, "Female", "Meerut"]
]
createBatchProfiles(newerData);
createSingleProfile("Sagar Sinha", 28, "Male", "Haryana");
//console logging updated result
console.log(PROFILELIST);