How To Check If An Array Value Exists

[Solved] How To Check If An Array Value Exists | Solidity - Code Explorer | yomemimo.com
Question : Check if the value exists in Array in Javascript

Answered by : putu-eka-mulyana

var army= ["Marcos", "DeltaForce", "Seals", "SWAT", "HeadHunters"];
if(army.indexOf("Marcos") !== -1) { console.log("Yes, the value exists!")
}else{ console.log("No, the value is absent.")
} 

Source : https://www.javatpoint.com/check-if-the-value-exists-in-array-in-javascript#:~:text=The%20indexof()%20method%20in,found%20and%20returns%20%2D1%20otherwise. | Last Update : Fri, 14 Oct 22

Answers related to how to check if an array value exists

Code Explorer Popular Question For Solidity