How do I return a random array into a text area? Having some trouble

Heres my code:

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();

I think its something with my loop here. Basically I want to get 2 pieces of into from a dropdown and then display the name of any bird that has those 2 pieces of info, but I want to pick a random bird. Right now using console log I am getting first letters of random birds I assume?

Project Link: App Lab - Code.org

filteredRandomizedBirdList = birdName[i];

Ask yourself what this does. It looks like you have assumed it will add a bird’s name to a list of birds. It doesn’t do that.

1 Like

Hello, right now your filtered bird list only ever holds one bird. In the line of code that Don highlighted, you are replacing the previous contents of that variable when I’m guessing you want to append it.

We’re you able to solve the issue?