-
-
Notifications
You must be signed in to change notification settings - Fork 36.3k
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
Bonfire: Make a Person: expect(Object.keys(bob).length) to equal 3 instead of 6. #877
Comments
@emptyteacup Thanks for the notifying us! Looks like this bonfire is causing a lot of confusion and I think it stems from the tests not being fully fleshed out (darn tests)... The main point to take away is that I, as a user of the object Person ands its instantiations, should not be able to directly change the first name of bob without using the method What the bonfire is looking for is to create variables scoped to the constructor and then create the instance methods in the constructor so they have access to these scoped variables do to closures. i.e. Function Person(firstandlast) {
var firstname = firstandlast.split(' ')[0]; // firstname is scoped to this function and not available outside
this.setFirstName = function(newFirst) { firstname = newFirst; } // because this function is created in Person constructor it has access to that firstname variable and any other variables declared in this scope.
}; Hope that helps! |
Thanks, I get it now. |
When doing this challenge, I passed all the tests except for the one described below:
expect(Object.keys(bob).length).to.eql(6);
I had to add the three blank variables (as indicated by the comments) in order to get the tests to pass so there seems to be a redundancy.
When I ran this on a separate editor with:
console.log(Object.keys(bob));
to see what it was searching for, I got:
[ 'firstAndLast', 'first', 'last'].
Just those three keys were what I needed to pass the tests. Have I failed to follow the instructions and write the program the right way or is this a valid issue?
The text was updated successfully, but these errors were encountered: