Sample code for Saving a record into array
we use push function to add the new data at the end of array list
//Save new students if new,otherwise update record
function saveStudentRecord(){
let student_name = document.getElementById('student_name');
let username = document.getElementById('username');
let password = document.getElementById('password');
if(password.value.length < 5){
alert("Password must be greater than 5 characters");
}else{
let new_student = {
id : students.length + 1,
student_name : student_name.value,
username : username.value,
password : password.value
}
if(editMode == true){
students[currentIndex] = new_student;
editMode = false;
currentIndex = -1;
}else{
students.push(new_student);
}
renderStudentList();
clearFields();
}
}