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.
- Check if the object contains a property named exactly "id".
- Return
trueif it does, andfalseif it does not.
01EXAMPLE 1
Input
user = { id: 123 }Output
trueConstraints
- Return a boolean (true/false).
CoreObjects
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
user{"id":123}
Expected Output
true
Click RUN to test your solution