Skip to content
Open

mvp #31

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
*/
function trimProperties(obj) {
// ✨ implement
}
var trimmedObj = {};
for (var prop in obj) {
if (typeof obj[prop] === "string") {
trimmedObj[prop] = obj[prop].trim();
} else {
trimmedObj[prop] = obj[prop];
}
}
return trimmedObj;
}

/**
* [Exercise 2] trimPropertiesMutation trims in place the properties of an object
Expand All @@ -18,8 +27,14 @@ function trimProperties(obj) {
* EXAMPLE
* trimPropertiesMutation({ name: ' jane ' }) // returns the object mutated in place { name: 'jane' }
*/
function trimPropertiesMutation(obj) {
function trimPropertiesMutation(object) {
// ✨ implement
for(var prop in object) {
if(typeof object[prop] === "string") {
object[prop] = object[prop].trim()
}
}
return object
}

/**
Expand Down
Loading