When a key that is not in the object is called, it returns undefined. I want to return a string that I specify instead of undefined. for example
let obj = {
key1: 'key1'
}
let res = obj.key2;
console.log(res);
I want console.log (res) to return "key not found", not undefined.
Is this possible?