Sha256: 576b3bb5f9b3cc728e4454347e0e1d41df7f8c36420f5a47a623a2fdd94202fb

Contents?: true

Size: 911 Bytes

Versions: 282

Compression:

Stored size: 911 Bytes

Contents

export default class GradeSchool {
    private roster = new Map<number, Set<string>>()

     addStudent( name: string, grade: number) {
        const students = this.roster.get(grade) || new Set<string>()
        students.add(name)
        this.roster.set(grade, students)
    }

     studentsInGrade( grade: number): string[] {
       const toReturn =  this.roster.get(grade) || new Set<string>()
         return Array.from(toReturn).sort()
    }

     studentRoster(): Map<string, string []>  {
         const temp =  new Map<string, string[]>()
         const keys: number[] = []

         for ( const key of this.roster.keys() ) {
             keys.push(key)
         }
         keys.sort()

         for ( const each of keys) {
            const values = this.roster.get(each) || new Set<string>()
            temp.set(each.toString(10), Array.from(values).sort())
         }

         return temp
    }
}

Version data entries

282 entries across 282 versions & 1 rubygems

Version Path
trackler-2.0.8.15 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.0.8.14 tracks/typescript/exercises/grade-school/grade-school.example.ts