Understanding how object work

I am trying to understand the code in question. what I don’t understand is on line 8 and 9
8. var someProp = propPrefix(“Name”); // someProp now holds the value ‘propName’
9. console.log(someObj[someProp]); // “John”

from my understanding is when we call a function with “” it means it is argument that get replace by parameter so this should print sName
and on line 9, it will reuntn someObj[sName] which won’t be found?

Even positing question confuses me.

1. var someObj = {
2.   propName: "John"
3. };
4. function propPrefix(str) {
5.   var s = "prop";
6.   return s + str;
7. }
8. var someProp = propPrefix("Name"); // someProp now holds the value 'propName'
9. console.log(someObj[someProp]); // "John"

Your code so far


// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line

var playerNumber;       // Change this line
var player = testObj;   // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36.

Challenge: Accessing Object Properties with Variables

Link to the challenge:

Both s and str are variables. In the example, the value of s is "prop" and the value of str is "Name", so the expression s + str is evaluated as "prop" + "Name", which is "propName".

"propName" is returned from the function call, and set as the value of someProp.

So someObj[someProp] is evaluated as someObj["propName"] (find the value at the propName key in someObj), which is "John".