Make Object Properties Private
See original GitHub issueChallenge Name
Make Object Properties Private
Issue Description
I am not able to find a bug in this snippet.
Browser Information
- Browser Name, Version:
- Operating System:
- Mobile, Desktop, or Tablet:
Your 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=0;
this.setGear=function(set){
return set;
};
this.getGear=function(){
gear += set;
};
};
var myCar = new Car();
var myBike = new Bike();
Screenshot
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to Make Private Properties in JavaScript - Webtips
The private keyword in object-oriented languages is an access modifier that can be used to make properties and methods only accessible inside the...
Read more >Is there a way to make private a javascript object property?
Use TypeScript and its private keyword. · Wait for JS enhancements for private fields, which may take the form #foo . · Use...
Read more >How to create Private Properties in JavaScript.
By default, JavaScript allows you to read and modify all the properties. But by using the Proxy objects, you can create private properties...
Read more >Private and protected properties and methods
In object-oriented programming, properties and methods are split into two groups: Internal interface – methods and properties, accessible from ...
Read more >Private properties in JavaScript - Curiosity driven
Another approach to storing private properties involves WeakMaps. An instance of WeakMap is hidden inside a closure and indexed by Person instances. The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @qkoots, thank you for your report. I’ll message you on gitter to explain the challenge a bit more. Please keep in mind that the GitHub issue tracker is for bugs only. If you need more help with the challenges, please use the chat rooms:
JavaScript help chat room Other Official Rooms
Thanks, and happy coding!
Hi @debashispanda, as pointed by @robbawebba your code is incorrect.
Thanks for the report. The issue tracker is for reporting bugs only.
Please use the chat rooms:
HTML/CSS help chat roomJavaScript help chat roomOther Official Roomsor try looking through our forum for help with a specific challenge.
Happy Coding!