This is the code from one of the Basic Javascript courses;
var someObj = {
propName: "John"
};
function propPrefix(str) {
var s = "prop";
return s + str;
}
var someProp = propPrefix("Name");
console.log(someObj[someProp]);
What I understood from this is that we returned the variable ‘s’ + str in the propPrefix function. And because we entered the string “Name” as the vlaue for (str) and the value of variable ‘s’ is set to “prop”, therefore it returned “propName”. Thus the console will show “John” as declared in the object’s property.
What I dont understand is, should it not return “prop”, “Name” (as two different strings or an array).