Javascript – How do I have a get/set in a method? (e.g. pineapple.is_a.fruit)

I have an assignment where I’m supposed to make magic out of programming. I’m unable to find any answers online, as I do not know the search term for it (tried method in a method etc…). Appreciate …