Substitute Algorithm

function foundPerson(people) {
 for(let i = 0; i < people.length; i++) {
 if (people[i] === "Don") {
 return "Don";
 }
 if (people[i] === "John") {
 return "John";
 }
 if (people[i] === "Kent") {
 return "Kent";
 }
 }
 return "";
}

image/svg+xml

function foundPerson(people) {
 const candidates = ["Don", "John", "Kent"];
 return people.find(p => candidates.includes(p)) || '';
}

AltStyle によって変換されたページ (->オリジナル) /