Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const studentData = [
- {
- name: 'Tim',
- status: 'Current student',
- course: 'Biology',
- },
- {
- name: 'Sue',
- status: 'Withdrawn',
- course: 'Mathematics',
- },
- {
- name: 'Liz',
- status: 'On leave',
- course: 'Computer science',
- },
- ];
- function enrollInSummerSchool(students) {
- /*1. create an array*/
- const studentsArray = [];
- /*2. Go through each object in given array of students */
- for (let i = 0; i < students.length; i++) {
- /*Update the value for each 'status' key */
- Object.assign({status : 'In Summer school'});
- /*populate newly created array */
- studentsArray.push(students[i])
- };
- return studentsArray;
- }
Add Comment
Please, Sign In to add comment