Skip to content

Comments

Zainab Alarbash - Raghad Butaiban#8

Open
ZainabAA wants to merge 2 commits intoJoinCODED:mainfrom
ZainabAA:main
Open

Zainab Alarbash - Raghad Butaiban#8
ZainabAA wants to merge 2 commits intoJoinCODED:mainfrom
ZainabAA:main

Conversation

@ZainabAA
Copy link

finished by Zainab Alarbash

const courses: string[] = [];
students.forEach(st => {
courses.push(...st.courses)
})
Copy link
Contributor

@Octowl Octowl Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the perfect place to use .reduce

const courses = students.reduce((allCourses, student) => [...allCourses, ...student.courses], []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants