challenge passes a sample test (myBike.gear should remain undefined)
Challenge Make Object Properties Private has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
var Car = function() {
// this is a private variable
var speed = 10;
// these are public methods
this.accelerate = function(change) {
speed += change;
};
this.decelerate = function() {
speed -= 5;
};
this.getSpeed = function() {
return speed;
};
};
var Bike = function() {
// Only change code below this line.
var gear = 4;
this.getGear = function(){
return gear;
};
this.setGear = function(change){
return gear;
};
};
var myCar = new Car();
var myBike = new Bike();
What is supposed to be the issue here? Your code looks correct and it passes. Do you believe it should not?
@SaintPeter Their setGear method isn't actually modifying the variable, they're just setting it to the number the test is expecting so it passes.
Oh my I have not used my email in soooo long ! Hey Rex, Logan is right some coders are having a difficult time passing the challenge and copy +pasting the "loophole" on gitter..... before others have a chance to really comprehend the challenge!
On Sun, Jan 17, 2016 at 11:57 AM, Logan Tegman [email protected] wrote:
@SaintPeter https://github.com/SaintPeter Their setGear method isn't actually modifying the variable, they're just setting it to the number the test is expecting so it passes.
— Reply to this email directly or view it on GitHub https://github.com/FreeCodeCamp/FreeCodeCamp/issues/6241#issuecomment-172371757 .
It sounds like we need several other setGear/getGear checks for values other that 4.
@tommygebru Your setGear function is wrong. It should accept the gear value and assign it to the gear variable and getGear fn will return the value.