School Catalogue


Can someone please help me understand why I am getting the following error in this particular step?


The method does indeed not exists. If i look at the method declaration and call:

pickSubstitudeTeacher // declaration 
pickSubstituteTeacher // call

i can indeed see they are not the same.

Got you! The error is gone now when I declared it to a variable. But, when trying to call it, I now get the following error:

That is a new error, have you looked into it? Its very similar to the error i help you solve, except know in a different place in the code

I have been staring at it and trying different things for 2 hours now with no result :frowning_face: I understand that undefined means that something needs to be declared but I cannot figure out how to make it work. Any tips? Perhaps I’ve been looking at it for too long…

You made another typo, the parameter at method deceleration is spelled differently then when you try to use it within the body of the pickSubstitudeTeacher method

Ok, got it. But if I change it it won’t log anything to the console. I guess what I was trying to do was to log one of the names from the pickSubstitudeTeacher array to the console. It wasn’t required in the specific exercise but I couldn’t really understand why it was necessary to include this array in the first place if I wasn’t going to use it? Hope this makes sense.

i don’t know what you changed, i would need to see that.

You pass an array of substitute teachers as argument to the parameter, but then when you attempt to use the parameter in the body of the method, you made another typo/spelling mistake.

I changed this:

Can you post your code? Either directly on the forum, or via github? working from screenshots is very difficult.

Of course, sorry;

so now we have a variable sub:

const sub = School.pickSubstitudeTeacher(['Jamal Crawford', 'Lou Williams', 'J. R. Smith', 'James Harden', 'Jason Terry', 'Manu Ginobli']);

which contains our substitute teacher, which we could log.

your getter here:

   get sportsTeams() {

logs the sportsTeams, it should return the sportsTeams so we can access the property outside the object.

if we now where to do:

alSmith.sportsTeams.push('new team');

we would get an error.

getters should return the property.

Ok, thank you. I have fixed the getter part. I think I got confused by the instructions provided on this one.
I have also now understood what you meant by the typo. Indeed, I had spelt the word substitute wrong everywhere, oops. Thanks for pointing this out! But I am still having trouble understanding how to log the substitute teacher? Is logging it like this wrong?

Why would you the substitute teacher like that? The method returns the substitute teacher, which you store in a variable named sub. So if you want to log the substitute teacher why not log this variable?

I see, I got it now. Guess I just needed to sleep and look at the code again. Thanks for all your help and for being patient!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.