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.

  1. Add a method called identify() to the object.
  2. The identify method should return this.name.
  3. Return the modified object.

Constraints

    Advancedthis
    JavaScript
    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