Hackathon and filteredList

My student is trying to change the random image to match the corresponding letter. Would if work by adding another setProperty? What would the code be for the indexing of the image and the letter? Thank you.

Hi @lashann.biondi,

Can you confirm that this is not for the student’s Create project?

Thank you!

–Michael K.

This is not a create task CB project. This is a unit 6 hackathon project. Thanks.

Hello @lashann.biondi,
you can do that however i found that this project really needs no filtering. but i did do a sort of pseudo filtering because the project probably wants that feel free to see what i’ve changed and do read the comments if your confused, if you have any other questions feel free to ask

// var index = 0; we already have the id of the table unecessary
var letters = getColumn("American Sign Language Alphabet", "Letter");
var images = getColumn("American Sign Language Alphabet", "Image");
var ids = getColumn("American Sign Language Alphabet", "id");
// these are all useless.... since your aren't filtering anything you don't need custom lists
// var filteredImageList = [];
// var filteredLetterList = [];
// var filteredIdList = [];
// However we can cahce the current set that was picked by the user
var letter = "";
var image = "";
var id = "";
onEvent("aslAlphaRan", "click", function () {
  setScreen("randomAlphabet");
  generateRandomSign();
});
// this is basically useless.... but if it's necessary i'll just bs my way through it
function filter() {
  for (var i = 0; i <= letters.length; i++) {
    if (letter == letters[i]) {
      image = images[i];
      id = ids[i];
    }
    // if (filteredImageList[i] == i) {
    //   appendItem(filteredImageList, image[i]);
    //   appendItem(filteredLetterList, letter[i]);
    //   appendItem(filteredIdList, id[i]);
    // }
  }
}
function update() {
  setText("letterA", "Letter " + letter);
  setProperty("image1", "image", image);
}

// no idea why you need this
// function randomImageFunction(id, index) {
//   var randomImage = image[index];
//   setProperty("image" + id, "image", randomImage);
// }
// instead do this this way when you implement Next for this you can just use this funcition
// instead of redoing when navigating to the first page
function generateRandomSign() {
  letter = letters[randomNumber(0, letters.length - 1)];
  filter();
  update();
}

Varrience