const army=["Marcos", "DeltaForce", "Seals", "SWAT", "HeadHunters"];
if(army.indexOf("DeltaForce") !== -1) {
console.log("exist")
} else {
console.log("not exist")
}
if(army.includes("DeltaForce")) {
console.log("exist")
} else {
console.log("not exist")
}
for(let i = 0; i < army.length; i++) {
if(army[i] === "DeltaForce") {
console.log("exist")
break
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter