The Self-Identity
Medium+25 XP
Mission Briefing
The sentient AI units are experiencing identity crises! We need to inject an identity protocol into their objects so they can introspect and declare their own names.
The Concept: This Context
In an object's method, the this keyword refers to the object itself. It allows the method to access the other properties stored within that same object!
The Objective
Your function receives an obj with varying properties including a name.
- Add a method called
identify()to the object. - The
identifymethod should returnthis.name. - Return the modified object.
Constraints
Advancedthis
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
obj{"name":"JS"}
Expected Output
{"name":"JS","identify":"___FN___:return function(){return this.name}"}Click RUN to test your solution