I want to iterate through a list that I created and then log random result based on conditional statement. However I am getting random first letters?

42 views Asked by At

I think it has something to do with my loop? I am using the AP code.org curriculum, ie. "getColumn" is one of their functions I believe.

var birdColor = getColumn("100 Birds of the World", "Primary Color");
var conservationStatus = getColumn("100 Birds of the World", "Conservation Status");
var birdName = getColumn("100 Birds of the World", "Name");
var filteredRandomizedBirdList = [];


//Global variable, these will be choices from the dropdown var colorChoice = "Black"; var statusChoice = "Least Concern";

function filter() {
  var index = 0;
  var color = birdColor;
  var status = conservationStatus;
  for (i = 0; i < birdColor.length; i++) {
    if (color[i] === colorChoice && status[i] === statusChoice) {
      filteredRandomizedBirdList = birdName[i];
      index = randomNumber(0, filteredRandomizedBirdList.length - 1);
      console.log(filteredRandomizedBirdList[index]);
      setText("textArea", filteredRandomizedBirdList);
    }
  }
}

filter();
0

There are 0 answers