Film Finder Javascript Project getSelectedGenre() error

Ive been up and down the project walkthrough and the forums and I seem to be the only one who gets a “could not find name” error on the getSelectedGenre() call even after reseting the workspace.

const getMovies = () => {
const selectedGenre = getSelectedGenre();

};

It can’t seem to see the function declared in helper.js. Is that supposed to be so without having changed the workspace at all or am I experiencing an anomaly?

1 Like

https://www.codecademy.com/courses/learn-intermediate-javascript/projects/js-film-finder

Its like there is supposed to be import/export code to bridge the gap but none of the examples I find have any.

1 Like

are you supposed to pass an argument to the function? Or is it supposed to deduce it implicitly from a global state?

It doesn’t require an argument. It pulls the value of the drop down menu item selected.

/ Returns the current genre selection from the dropdown menu
const getSelectedGenre = () => {
const selectedGenre = document.getElementById(“genres”).value;
return selectedGenre;
};

If two files are on the same file level do you have to import/export or are they visible to each other? The call is in script.js and the function declaration is in helper.js, both of with are in the public folder.

But actually what was the actual error message along with the traceback. Could not find name of what, the function, or the value the function is fetching.

How are you getting the error message? Are you checking the console?

It doesn’t throw a hard error it just has an info handle on the variable.

Screenshot 2024-01-26 at 11.55.38 AM

The console report mostly just reiterates.

“A form field element should have an ID or name attribute”

I think that’s just the code editor not capturing it. You don’t need to import it.

For example if you go into helpers and log foo, then invoke the parent function getMovies(); in your script, it will log foo in the console (just tested it, it’s no issue). This would not happen if it really couldn’t find getSelectedGenre.

I guess the best thing if you want to read text editor prompts is to set up your own IDE. But I’m still wary of them. Even the compiler errors for C++ or Rust are only hints to the actual if any. For that reason, it’s good to be proactive in setting expectations and use all the dev tools to be constructive (debuggers, etc). In this case, it’s just a config error, but will not prevent the function from running as intended.