As a newcomer to JavaScript, I am facing an issue while trying to create a simple program. I am attempting to store the variables 'name', 'document', and 'code' inside the JSON array called 'records'.
var records = [];
var code = 1;
function save() {
var name = document.getElementById("pName").innerText;
var doc = document.getElementById("pDocument").innerText;
var record = {
code: 0,
name: "",
sex: ""
};
record.push(code, name, doc);
}