Hi, I don’t really understand why n has to declared in the render() for it to work.
It does not make sense logically if n is declared in the class component as it will always be a static value once the class component is called, but I would still expect it to run.
Hi there! Hopefully you already have an answer, if not hopefully I can give some clarity.
It is considered a convention of naming Classes to always use UpperCamelCase, in order to distinguish classes from other objects. This isn’t strictly built into the language, but is a best practice used my a majority of developers.
The injection of {friend.title} is used because in the lines above we assigned one of the elements of the friends object to a variable, friend.
const friend = friends[1];
So when injecting the JavaScript we are injecting that specific object of the array of friends objects, and accessing that specific title.
It’s kinda like saying ‘I want to access this friend’s title’. If we used friends.title there would be an error because title is not a property of the friends object.
Hope this helps clear it up, if not hit me up and I can try explain a little better, its still early in the morning for me