My initial implementation of the .has() method (steps 19 - 22) used dot notation and did NOT work
has(object,key){
if (object.key != undefined){
return true;
} else {
return false
}
}
when I change the dot notation to bracket notation it WORKS.
has(object,key){
if (object[key] != undefined){
return true;
} else {
return false
}
}
A previous lesson said:
We must use bracket notation when accessing keys that have numbers, spaces, or special characters in them. Without bracket notation in these situations, our code would throw an error.
Why did this fail using dot notation? Is undefined a special character??