This snippet of code has the values I list in the comments.
var studentid = course.roster[i]; // studentid = 1367
console.log(studentid); // prints 1367
console.log(students[1367]); // correctly prints a student object
If I change the key in the third line to use a variable with the exact same value, then the result is undefined. Why?
console.log(students[studentid]); // fails to print correctly
This is the output from console.log(students[1367]):
Object {
lname: "John",
fname: "Smith",
grade: "Sophomore",
id: "1367",
email: "[email protected]"
}
This is the output from console.log(students[studentid]):
undefined
studentidis return string