Repository navigation
In progress
Copy link
Labels
js v9 certThis is for the JS V9 certification.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.status: waiting triageThis issue needs help from moderators and users to reproduce and confirm its validity and fix.
Description
Describe the Issue
Inconsistency when using equality and strict equality to increment counters in Build a Campus Directory Normalizer.
Step 47
Inside the loop, check if instructorValues[i].officeHours == null. If true, increment missingOfficeHours by 1.
Step 50
Inside the loop, check if programValues[i].room === null. If true, increment programsWithoutRooms by 1.
Affected Page
Your code
const rawData = {
"Computer Science": {
Dept_code: "CSE",
programs: [
{
id: "CSE101",
name: "Database Management System",
room: "405",
instructors: [
{ id: "INS001", name: "Alejandro", email: "[email protected]", officeHours: "Sun-Tue 10AM-12PM" },
{ id: "INS002", name: "Kenji", officeHours: null },
],
},
{
id: "CSE102",
name: "Data Structures",
room: null,
instructors: [
{ id: "INS003", name: "Fatima", email: "[email protected]", officeHours: "Mon-Wed 10AM-2PM" },
],
},
{
id: "CSE103",
name: "Operating Systems",
room: "401",
instructors: [
{ id: "INS005", name: "Wei", email: "[email protected]", officeHours: "Thu 1PM-3PM" },
],
},
],
},
"Business Administration": {
Dept_code: "BBA",
programs: [
{
id: "BBA101",
name: "Financial Accounting",
room: "201",
instructors: [{ id: "INS004", name: "Sofia", email: "[email protected]" }],
},
{
id: "BBA102",
name: "Marketing Management",
room: "204",
instructors: [
{ id: "INS006", name: "Robin", email: "[email protected]", officeHours: "Tue-Thu 9AM-11AM" },
],
},
{
id: "BBA103",
name: "Business Law",
room: "203",
instructors: [
{ id: "INS007", name: "Priya", email: "[email protected]", officeHours: "Mon 2PM-4PM" },
],
},
],
},
};
function normalizeDirectory(rawData) {
const departmentsById = {};
const programsById = {};
const instructorsById = {};
const instructorsByEmail = {};
const departmentEntries = Object.entries(rawData);
for (let i = 0; i < departmentEntries.length; i++) {
const [departmentName, departmentData] = departmentEntries[i];
const departmentId = departmentData.Dept_code || `dept-${i + 1}`;
departmentsById[departmentId] = {
id: departmentId,
code: departmentData.Dept_code,
name: departmentName,
programIds: [],
};
for (let j = 0; j < departmentData.programs.length; j++) {
const program = departmentData.programs[j];
programsById[program.id] = {
...program,
departmentId,
};
departmentsById[departmentId].programIds.push(program.id);
for (let k = 0; k < program.instructors.length; k++) {
const instructor = program.instructors[k];
instructorsById[instructor.id] = {
...instructor,
programId: program.id,
departmentId,
};
if (instructor.email) {
instructorsByEmail[instructor.email] = instructor.id;
}
}
}
}
return {
departmentsById,
programsById,
instructorsById,
instructorsByEmail,
};
}
const normalizedData = normalizeDirectory(rawData);
function getInstructorByEmail(email, normalizedData) {
const instructorId = normalizedData.instructorsByEmail[email];
if (!instructorId) {
return "Instructor not found";
}
const instructor = normalizedData.instructorsById[instructorId];
const department = normalizedData.departmentsById[instructor.departmentId];
return {
name: instructor.name ?? "Unknown Instructor",
officeHours: instructor.officeHours ?? "Not Available",
department: department.name ?? "Unknown Department",
};
}
function listRoomsByBuilding(buildingCode, normalizedData) {
const programValues = Object.values(normalizedData.programsById);
const rooms = [];
for (let i = 0; i < programValues.length; i++) {
const program = programValues[i];
const department = normalizedData.departmentsById[program.departmentId];
if (department.code === buildingCode && program.room != null) {
rooms.push(program.room);
}
}
rooms.sort();
return rooms;
}
function renderDirectorySummary(normalizedData) {
const departments = Object.keys(normalizedData.departmentsById).length;
const programs = Object.keys(normalizedData.programsById).length;
const instructors = Object.keys(normalizedData.instructorsById).length;
const instructorValues = Object.values(normalizedData.instructorsById);
let missingOfficeHours = 0;
for (let i = 0; i < instructorValues.length; i++) {
}
}
Expected behavior
Step 50 should also use equailty instead of strict equality, so the single "if" condition checks for both a 'null' value and 'undefined' if the key value pair is missing
Maybe a brief explanation as to why equality is used over strict equality in Step 47s description
Screenshots
No response
System
- Device: [e.g. iPhone 6, Laptop]
- OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
Additional context
No response
Metadata
Metadata
Assignees
Labels
js v9 certThis is for the JS V9 certification.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.status: waiting triageThis issue needs help from moderators and users to reproduce and confirm its validity and fix.
Activity
polyvexr commentedon Nov 25, 2026
Hi! Could a maintainer clarify whether the use of
=== nullin Step 50 is intentional?Step 48 specifically describes programs whose
roomis explicitlynull, which makes me think the strict equality check may be deliberate. However, Step 40 usesprogram.room != null, which also handlesundefined.Should Step 50 count only explicitly null values, or should it also account for programs where the
roomproperty is missing (undefined)?I'd be interested in working on this issue if a change is needed. If maintainers agree that the behavior should be updated, could you please assign it to me? I'd be happy to implement the fix and submit a PR.
Thanks!
syedryaaan commentedon Nov 25, 2026
Hi @Gazdean,
I'd love to take ownership of this issue and contribute a fix.
After reviewing the issue, I believe Step 50 should use
== nullinstead of=== null, matching the behavior in Step 47. This would ensure that bothnullandundefinedvalues are handled correctly when checking for missing room properties.I'd like to:
Could you please assign this issue to me and allow me to work on it? I'll make sure to follow the repository's contributing guidelines and submit a clean, tested PR.
Thank you!