I have been working with the basics of JavaScript arrays and here is my code snippet:
let arr = ['students', 'exams', [{'sub1':80, 'sub2':60},{'grade_sub1':'A', 'grade_sub2':'B'}]];
let new_arr = [];
new_arr = new_arr.concat(arr);
console.log(new_arr); //output : ['students', 'exams', [{'sub1':80, 'sub2':60},{'grade_sub1':'A', 'grade_sub2':'B'}]]
new_arr[2].pop();
let sub_arr = [];
sub_arr = sub_arr.concat(arr);
console.log(sub_arr); //output: ['students', 'exams',[{'sub1':80, 'sub2':60}]]
The expected output for sub_arr is
['students', 'exams', [{'sub1':80, 'sub2':60},{'grade_sub1':'A', 'grade_sub2':'B'}]]
I attempted to use slice()
but it did not yield the desired results. Please assist me with this issue.