Skip to content
Advertisement

Component in vanilla Javascript?

I have tried to create to create a component in vanilla JavaScript here in main js file I am trying to call a function that is defined in a component and also I am expecting an output but it gives me error saying showMovies is not a function. Can anyone tell me what is right way to do so:

JavaScript
JavaScript

Advertisement

Answer

The component you have defined here is a function that consists a function called showMovies. But as you have not returned the function, it will be inaccessible. To be able to use it, you may return the function.

JavaScript

Now you can use the function using Component().showMovies(SEARCHAPI + searchTerm)

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement