ds-algo-study
Version:
Just experimenting with publishing a package
19 lines (13 loc) • 576 B
JavaScript
/***********************************************************************
Write a function `doesKeyExist(obj, key)` that takes in an object and a
key and returns true if the key is inside the object and false if the
key is not inside the object.
Examples:
let obj1 = {bootcamp: 'App Academy', course: 'Bootcamp Prep'}
doesKeyExist(obj1, 'course'); // => true
doesKeyExist(obj1, 'name'); // => false
***********************************************************************/
function doesKeyExist(obj, key) {
return obj[key] !== undefined;
}
module.exports = doesKeyExist;