Question: I have a JAVASCRIPT code that I need help fixing. It is for my app, that gives the user options to chose a 'Country', 'Movie
I have a JAVASCRIPT code that I need help fixing. It is for my app, that gives the user options to chose a 'Country', 'Movie Genre', and choice of either 'movie' or 'tv show'. I have a table called NetflixContent that has the list of all the movies. I am having trouble outputting a movie suggestion. When the user picks a country, genre, and movie/ tv show, it'll just show a blank screen rather than a movie option for the table I have. I just need to add code to make the app give out an output for the NetflixContent table I have created. Here is the code I have so far:
//
var contentList = [(getColumn("Netflix Content", "Type"))];
var allContentList = [(getColumn("Netflix Content", "Title"))];
var genreList = [(getColumn("Netflix Content", "Genre"))];
var countryList = [(getColumn("Netflix Content", "Country"))];
var NetflixContentIndex = allContentList.length-1;
//
var filteredContentList = [];
var filteredAllContentList = [];
var filteredGenreList = [];
var filteredCountryList = [];
//
onEvent("beginButton", "click", function( ) {
setScreen("customizePage");
});
//
onEvent("generateButton", "click", function( ) {
var typeInput = getText("contentInput");
var countryInput = getText("countryInput");
var genreInput = getText("genreInput");
for (var i = 0; i < contentList.length; i++) {
console.log(contentList);
}
listFormat();
setScreen("suggestionsScreen");
});
function updateScreen() {
setProperty("contentOutput", "text", filteredAllContentList[NetflixContentIndex]);
}
//
onEvent("homeButton1", "click", function( ) {
setScreen("homeScreen");
});
//
onEvent("homeButton2", "click", function( ) {
setScreen("homeScreen");
});
//
function listFormat() {
filter();
updateScreen();
}
//
function filter() {
}
//
//Input of user and start of fuctions
onEvent("generateButton", "click", function( ) {
listFormat();
});
//First function ran, runs filter and update screen every click of the butoon
function listFormat() {
filter();
updateScreen();
}
//Connects the filtered lists to the other lists by using a for loop and appending
function filter() {
for (var i = 0; i < NetflixContentIndex.length; i++) {
if (NetflixContentIndex[i] == 1) {
appendItem(filteredContentList, contentList[i]);
appendItem(filteredAllContentList, allContentList[i]);
appendItem(filteredGenreList, genreList[i]);
appendItem(filteredCountryList, countryList[i]);
}
}
}
//Update function that randomizes the index
function updateScreen() {
setProperty("contentOutput", "text", filteredAllContentList[NetflixContentIndex]);
}
//
This is a link to all of the info from the data table:
ile:///home/chronos/u-271a883a7741b444f2a60ca68fbafd21571ffe78/MyFiles/Downloads/Netflix%20Content%20(4).csv
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
