Need help with js function

im doing this qualification bootcamp and i cant seem to get it to work properly. it should just return true without those two annoying errors at the bottom of the pic.
this is the pic with question, code and errors:

i tried different methods like just calling the function name and now console.log returns true like its supposed to but its giving 2 other errors in this bootcamps specific editor.
jsfiddle, jsbin and the browsers console just returns true without any errors.

here is written code i have done:

var registrationNumber = “CY123”;

function isFromBellville() {
  return registrationNumber.startsWith("CY")
};

console.log(isFromBellville());

please let me know how i can fix this error.

Is this function supposed to take the registrationNumber as an argument instead of referencing a global variable?

I would expect a function like that to have a parameter
otherwise how can it be tested with different input?

1 Like

it gives a type error: cant read property if i insert registrationNumber as a parameter

What does your code look like when you try to do that?

if i put registrationNumber as an argument i get the same error as in the picture

In the picture you do not have the registrationNumber as a function argument.

i know but i tried it alredy

Please show us the code of you doing so.

here is the pic:

That code does not have the registrationNumber being used as a function argument and is still referencing the global variable.

Have you created functions with arguments before? This freeCodeCamp tutorial may be helpful.

i used it at the top as a parameter as well and it gave a type error: cannot read property

What do you mean by “used it at the top as a parameter”? Can you share code of you doing so?

1 Like

thank you for your time. my mentor will explain the problem to us right now