Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joey bertschler #36

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
first two tests run
  • Loading branch information
JoeyBertschler committed Oct 7, 2021
commit 5e42be09b1295388ec2122c50c698d7c96e66c65
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
* EXAMPLE
* trimProperties({ name: ' jane ' }) // returns a new object { name: 'jane' }
*/
function trimProperties(obj) {
function trimProperties(obj) { //now an argument is passed through our function
// ✨ implement
let result = {}
for (let prop in obj) {
result[prop] = obj[prop].trim()
}
return result
}


/**
* [Exercise 2] trimPropertiesMutation trims in place the properties of an object
* @param {object} obj - an object with properties that are strings
Expand Down
8 changes: 6 additions & 2 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ const utils = require('./index')
describe('[Exercise 1] trimProperties', () => {
test('[1] returns an object with the properties trimmed', () => {
// EXAMPLE
const input = { foo: ' foo ', bar: 'bar ', baz: ' baz' }
const input = {foo: ' foo ', bar: 'bar ', baz: ' baz' }
const expected = { foo: 'foo', bar: 'bar', baz: 'baz' }
const actual = utils.trimProperties(input)
expect(actual).toEqual(expected)
})
// test('[2] returns a copy, leaving the original object intact', () => {})
test('[2] returns a copy, leaving the original object intact', () => {
const input = {foo: ' foo ', bar: 'bar ', baz: ' baz'}
utils.trimProperties(input)
expect(input).toEqual({foo: ' foo ', bar: 'bar ', baz: ' baz'})
})
})

describe('[Exercise 2] trimPropertiesMutation', () => {
Expand Down
Loading