From a30d6f799997b2aed1a4c8a30d34b4dd45ea80d8 Mon Sep 17 00:00:00 2001 From: abdullah Date: Thu, 24 Jul 2025 17:23:38 +0300 Subject: [PATCH] A --- src/students.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/students.ts b/src/students.ts index ac9d6c0..dd5f2dc 100644 --- a/src/students.ts +++ b/src/students.ts @@ -72,7 +72,7 @@ const students: Student[] = [ function getStudentName(student: Student): string { // write your code here... - return ""; // replace empty string with what you see is fit + return student.name; // replace empty string with what you see is fit } /** @@ -87,7 +87,7 @@ function getStudentName(student: Student): string { function getCourse(student: Student, courseIndex: number): string { // write your code here... - return ""; // replace empty string with what you see is fit + return student.courses[2]; // replace empty string with what you see is fit } /** @@ -103,6 +103,8 @@ function getCourse(student: Student, courseIndex: number): string { */ function addCourseToStudent(student: Student, course: string): Student { // write your code here... + const addCourse = student.courses; + addCourse.push(course); return student; } @@ -116,8 +118,9 @@ function addCourseToStudent(student: Student, course: string): Student { */ function countCourses(student: Student): number { // write your code here... + //const countCourses = student.coursesc - return -1; // replace -1 with what you see is fit + return student.courses.length; // replace -1 with what you see is fit } /** @@ -133,6 +136,9 @@ function countCourses(student: Student): number { */ function removeCourseFromStudent(student: Student, course: string): Student { // write your code here... + // const removeCourseFromStudent = student.courses; + // removeCourseFromStudent.filter((removeCourseFromStudent) => student.courses !== c ); + student.courses = student.courses.filter((c) => c !== course); return student; } @@ -156,7 +162,7 @@ function findStudentById( ): Student | undefined { // write your code here... - return undefined; // replace undefined with what you see is fit + return students.find((student) => student.id === studentId); // replace undefined with what you see is fit } export {