My students are accessing data and filtering the data. We want to access the data (which we know how to do), go through each line of the data (which we know how to do), and filter the data based on the name associated under one of the columns.
We want the code to read the data and filter out only the movies made a specific country and put those Title Names into a new list (Name).
Below is an example of what a student is attempting to do.
var Title;
var Name = ;
var USTV = ;
var Local ;
function US() {
Title = getColumn(“Netflix Content”, “Title”);
Local = getColumn(“Netflix Content”, “Country”);
for (var i = 2750; i < 4500; i++) {
if (Local[i]== “Uruguay”) {
appendItem(USTV, Local[i]);
appendItem(Name, Title [i]);
}
}
}
onEvent(“button1”, “click”, function() {
US();
});
John
// basically just ensure that what your looking for actually exists in the index rage you have
var Name = [];
var USTV = [];
function US() {
// search method was good, cleaned it up a bit
// search index contained none of the results you were looking for (fixed by allowing it to read to the end of the list)
// we return Name; however since your using global arrays you can also access this varriable outside of the function
var Titles = getColumn("Netflix Content", "Title");
var Locales = getColumn("Netflix Content", "Country");
for (var i = 2750; i < Titles.length; i++) {
if (Locales[i].toLowerCase() == "uruguay") {
console.log(Locales[i])
appendItem(USTV, Locales[i]);
appendItem(Name, Titles[i]);
}
}
return Name;
}
onEvent("button1", "click", function () {
// based on our example we can use this
console.log(US());
// or put them on a line basis
US();
console.log(Name);
});
from my understanding most of this was correct below are 2 methods of which you can call & display the results of the index search being performed, only thing i will say is possibly try to expand the search index otherwise you will just get an empty array of which was what i was getting
Varrience