The Property Guard

Medium+15 XP

Mission Briefing

The Gatekeeper needs to check if the incoming traveler has a specific security badge listed in their credentials. If they have the exact badge, they can pass.

The Concept: Membership Check

How do you check if an object specifically has a certain key? You can use the .hasOwnProperty(key) method or the in operator! Example: user.hasOwnProperty("id"); // true or false

The Objective

Your function receives a user object.

  1. Check if the object contains a property named exactly "id".
  2. Return true if it does, and false if it does not.

01EXAMPLE 1

Inputuser = { id: 123 }
Outputtrue

Constraints

  • Return a boolean (true/false).
CoreObjects
JavaScript
Loading...
3 Hidden

Input Arguments

user{"id":123}

Expected Output

true

Click RUN to test your solution