Film finder movies.length undefined?

Hello, I am attempting to complete the Movie Finder exercise and I have gotten to the last step but it will not work. I tried to check the console to see what is wrong. it is telling me that It is creating an issue where on line 76 of the helpers.js (const randomIndex = Math.floor(Math.random() * movies.length):wink: says that .length is a type error as it is undefined. how do I fix this? the variable which gives the type error is movies.

const tmdbKey = '8fb79842c02751b3387b711b974e60d5'; const tmdbBaseUrl = 'https://api.themoviedb.org/3'; const playBtn = document.getElementById('playBtn'); const getGenres = async () => { const selectedGenre = getSelectedGenre(); const discoverMovieEndpont = '/discover/movie' const genreRequestEndpoint = '/genre/movie/list'; const requestParams = `?api_key=${tmdbKey}`; const urlToFetch = `${tmdbBaseUrl}${genreRequestEndpoint}${requestParams}` try{ const response = await fetch(urlToFetch) if (response.ok === true){ const jsonResponse = await response.json(); genres = jsonResponse.genres return genres } } catch (error) { console.log(error); } }; const getMovies = async () => { const selectedGenre = getSelectedGenre(); const discoverMovieEndpoint = '/discover/movie'; const requestParams = `?api_key=${tmdbKey}&with_genres=${selectedGenre}`; const urlToFetch = `${tmdbBaseUrl}${discoverMovieEndpoint}${requestParams}`; try{ const response = await fetch(urlToFetch) if(response.ok === true){ const jsonResponse = await response.json() //console.log(jsonResponse) const movies = jsonResponse.results //console.log(movies) getMovies(); } } catch (error){ console.log(error) } }; const getMovieInfo = async (movie) => { const movieId = movie.id; const movieEndpoint = `/movie/${movieId}` const requestParams = `?api_key=${tmdbKey}`; const urlToFetch = `${tmdbBaseUrl}${movieEndpoint}${requestParams}`; try{ const response = await fetch(urlToFetch) if(response.ok === true){ const jsonResponse = await response.json() const movieInfo = jsonResponse.results return movieInfo } } catch(error){ console.log(error) } }; // Gets a list of movies and ultimately displays the info of a random movie from the list const showRandomMovie = async () => { const movieInfo = document.getElementById('movieInfo'); if (movieInfo.childNodes.length > 0) { clearCurrentMovie(); }; const movies = await getMovies(); const randomMovie = getRandomMovie(movies); const info = await getMovieInfo(randomMovie); console.log(jsonResponse) displayMovie(info); }; getGenres().then(populateGenreDropdown); playBtn.onclick = showRandomMovie;

Thereโ€™s a problem in your getMovies function

The function does not return anything.
getMovies();
should be
return movies;