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.2.1.180 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.179 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.178 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.177 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.176 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.175 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.174 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.173 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.172 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.171 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.170 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.169 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.167 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.166 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.165 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.164 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.163 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.162 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.161 tracks/typescript/exercises/grade-school/grade-school.example.ts
trackler-2.2.1.160 tracks/typescript/exercises/grade-school/grade-school.example.ts