question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Waypoint: Make Object Properties Private - Instruction Clarity

See original GitHub issue

I have addressed a number of questions regarding this Waypoint over that past week. While I don’t believe the wording of the instructions is to blame for all the confusion, perhaps some clarity could be added at the end to help users understand what needs to be done while also reinforcing the terminology. Additions in bold, deleted text struck through.

Properties Private

Objects have their own attributes, called properties, and their own functions, called methods.

In the previous challenge, we used the this keyword to reference public properties and public methods of the current object.

We can also create private properties and private methods, which aren’t accessible from outside the object.

To do this, just declare properties or functions within the constructor without the this keyword.

Let’s create an object with two functions. One attached as a property and one not.

See if you can keep myBike.speed and myBike.addUnit private, while making myBike.getSpeed publicly accessible. See if you can modify the Bike constructor so that both the speed property and the addUnit method are private, while also making the getSpeed method publicly accessible for all objects created from the Bike constructor. We’ll check your work by testing the myBike object we’ve created from the Bike constructor at the bottom of the code.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
ysroelscommented, Dec 30, 2015

after countless attemps i got this to pass:

 var gear = 0;

  this.setGear = function() {
    gear += 4;
  };

  this.getGear = function() {
    return gear;
  };

can someone please explain why / what happened??

10reactions
interglobalmediacommented, Apr 6, 2016

The instructions for this exercise were very confusing. I got everything that you got, @saifalizafar except for the gear = set. I was trying to do something similar to get getGear to be equal to setGear, but no go. Will try this now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Waypoint Class | STK Components for .NET 2022 r2 - AGI
Waypoint Class ; Protected method, Finalize. Allows an object to try to free resources and perform other cleanup operations before it is reclaimed...
Read more >
Private properties in JavaScript ES6 classes - Stack Overflow
WeakMaps associate data with Objects (here, class instances) in such a way that it can only be accessed using that WeakMap. So, we...
Read more >
Direct request—ArcGIS REST APIs
1 (Waypoint)—A location that the route will travel through without making a stop. Waypoints can be used to force the route to take...
Read more >
Waypoint Class Reference - Mapbox docs
A waypoint object indicates the location's geographic location along with other optional information, such as a name or the user's direction approaching the ......
Read more >
Halo: The Master Chief Collection (MCC) Update – April 2022
The in-game link to Halo Waypoint's credits now works as expected. The "Set for all games" button in the keybinding settings menu will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found