I am trying to loop out a list of names and console.logging the values that match. Am I going wrong using (if value in array)?
for (var i = 0; i < this.state.apiResponse.length ; i++) {
var selectedChars = this.state.chosenChars
var returnedChars = this.state.apiResponse[i].name
console.log(selectedChars)
console.log(returnedChars)
// I think i'm making a mistake with this if statement
if (returnedChars in selectedChars) {
console.log(this.state.apiResponse[i].name);
}
The selectedChars array and returned values:
["Luke Skywalker", "Han Solo"]
Luke Skywalker
Han Solo
Chewbacca