There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
console.log(nurseOlynyk._certifications[2]) of genetics
This line of code generates the correct answer to the activity on screen 10 but doesn’t lead to correct response on webpage.
Thanks, i’ll may check into that later. Having to deal with some practical stuffs/other stuff so haven’t look back into Javascript on CodeAcademy in a few weeks. That sounds like a good catch.
Don’t be mislead into thinking the underscores are of no particular significance. Architecturally they are vitally important and cannot for a second be written off.
We’re in a different domain once setters and getters are introduced. Forget that we can sort of do the same thing without them. With them we have another level of functionality. Not just another level, a whole universe of inspection, validation, composition, reporting, &c. Not the sort of thing we would expect to find in a property definition.
Consider,
this._prop = value;
// ...
get prop () {
return this._prop;
}
set prop (value) {
// validate value
this._prop = value;
}
We’ve essentially created a backing variable using the very setter intended to work with one. The getter will now work as expected.
Perhaps you can explain why we cannot perform both operations at once? There seems to be some restriction in place. Any ideas?
Proof the setter is run…
> class a {
constructor(value) {
this._prop = value;
}
get prop () {
return this._prop;
}
set prop (value) {
// validate value
this._prop = value;
}
}
<- undefined
> b = new a('funny')
<- > a {_prop: "funny"}
> b._prop
<- "funny"
At this point we confirm the endpoint. Now we want to validate the data before it reaches the endpoint.
I wasn’t writing off the underscores. The comment of pratical was in reference to needing to deal with some real life issues before getting back to codeacademy problem and finding a solution. Thanks for your assistance.
My biggest issue going through codeacademy thus far has nothing to do with explanations. Actually, this question is rather easy. The way they present the questions are very confusing where I actually view the solution to understand the question.
Should never be like that. For example, this questions specfically states properties and methods but to a new developer can be confusing because thought process is … do we create new properties on the new object or is it already understood as it’s being inherited through extends.
So, I wish CodeAcademy would go through some of their questions and just ask the question and not convolute everything.
It says in the lesson that we should use this code to inherit a new child class that is exactly the same as its parent class:
But I just felt that this piece below should do it, and I tried it and it’s working well, is there anything wrong with it? and if not, why aren’t we using it since it’s more efficient?
This is not so right implementation. According to object oriented concepts if a parent class constructor expects arguments then it is the responsibility of its child class to pass the value for parent when trying to create objects. Check this piece of code.
I did not find an explanation, I can do better ;). I can think myself of a reason why it happened.
If you put an array with the push function in the console log it will log the amount of items that are in the array after the push. So if you assign it to a variable (that contains an array) the variable will replace the array with a number instead.
Hi! why exactly on the inheritance V exercise when adding a method to the child class the console will reference error if I type the method like:
this.addCertifications(certifications) {
this._certifications.push(newCertification);
}
Nevertheless when I take the first this. everything starts working right? the code ends up like: