Implement the removeProperty function that takes an object and a property name
Implement the removeProperty function that takes an object and a property name and does the following: If object obj has property prop, it removes the property from the object. If the property has been removed, it returns true; otherwise it returns false. What is wrong with this code? function removeProperty(obj,prop) { if(obj.hasOwnProperty('prop')) { console.log(obj); delete obj.prop; return true; } else { return false; } } var obj= { name:"John" }; removeProperty({obj,'name'});
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.