in javascript closed closed loops will be used with a function

You can iterate through arr and return Found Droid as soon as you find it, or if not found return with not found.

Simple approach as below.

function droids(arr) {
  for(var str of arr) {
      if (str  === 'Droids') {
       return 'Found Droid';
    }
  }
 return `These are not the droids you're looking for`;
}

// Uncomment these to check your work! 
const starWars = ["Luke", "Finn", "Rey", "Kylo", "Droids"]
const thrones = ["Jon", "Danny", "Tyrion", "The Mountain", "Cersei"]
console.log(droids(starWars)) // should log: "Found Droids!"
console.log(droids(thrones)) // should log: "These are not the droi

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top