Tell us what’s happening:
I just do not understand this code example at all.
I dont understand why is there a function like that,
what is that s= “prop”;
why is it returning s+str
why then “const someProp”,
it feels like theres so much zig zagging just to get the name “John”, so overwhelming…
**Your code so far**
const someObj = {
propName: "John"
};
function propPrefix(str) {
const s = "prop";
return s + str;
}
const someProp = propPrefix("Name");
console.log(someObj[someProp]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Accessing Object Properties with Variables
Link to the challenge: