-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9be8d80
commit 73d9d35
Showing
2 changed files
with
9 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
Javascript Objects/Check if property exists in object and is truthy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Write a function that takes an object (a) and a string (b) as argument | ||
// Return true if the object has a property with key 'b', but only if it has a truthy value | ||
// In other words, it should not be null or undefined or false | ||
// Return false otherwise | ||
|
||
function myFunction(a, b) { | ||
return !!a[b] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters