Sha256: 852c65a5d3b24b23fa69986ba2cb1cf14748b9d8ee567901dc94a66714bcc660
Contents?: true
Size: 666 Bytes
Versions: 68
Compression:
Stored size: 666 Bytes
Contents
module.exports = function School() { var db = {}; function add(student, gradeLevel) { if (db[gradeLevel]) { db[gradeLevel].push(student); } else { db[gradeLevel] = [student]; } } function grade(level) { return db[level] ? clone(db[level]).sort() : []; } function roster() { return sortedGrades().reduce(function (sorted, gradeLevel) { sorted[gradeLevel] = clone(db[gradeLevel]).sort(); return sorted; }, {}); } function sortedGrades() { return Object.keys(db).sort(); } return { roster: roster, add: add, grade: grade }; }; function clone(array) { return array.slice(); }
Version data entries
68 entries across 68 versions & 1 rubygems