JSFiddle - React, Tailwind, and code Playground

by Joe Saad

HTML

<div id="place">checking if an element is within an array or not</div>

JavaScript

$(document).ready(function(){

    var arr = [ "Adam", "Pete", "Samson", "John" ];   
    
    alert($.inArray("John", arr));
   

    if ($.inArray("John", arr)>-1) {
        alert('found');
    }
    else{
        alert('not found');
    }


});