How FCC check function name

Hello everyone

I just want to ask about how freecodecamp check our code.

I did a getter and setter topic in Algo and DS certification track, and eventough my code has no logical error, the test only passed if i rename my setter and getter to “temperature”. Is this only a bug or do we really have to use precise and predefined name for our function and method ?

Thanks

Hi and welcome to the forum.

You really have to use the precise name for required methods. This is a theme that you will see throughout coding. Certain methods need to be implemented with specific names in order to match requirements for various reasons.

1 Like

Hi @fattah_abdul!

Welcome to the forum!

I also want to add that the tests are looking for specific keywords or else it won’t pass.

If you are curious here is a link to the challenge and tests.

To expand on this:

In this case, your getter and setter look like so:

get temperature() {
  //stuff
}
set temperature(param) {
  //other stuff
}

Both of these refer to the temperature property of the class you’re creating.

console.log(this.temperature) // uses the getter
this.temperature = 9000 // uses the setter

The tests ask you to write a getter and setter for the temperature, which is why the name must be specific. If you wanted to write a getter and setter for a kittens property, you could do so:

get kittens() {
  // meow
}
set kittens() {
  // purr
}
1 Like