JSFiddle - React, Tailwind, and code Playground

HTML

<div id="output"></div>

JavaScript

// write to html and console.log
function output(x){    
	console.log(x);
    $("#output").append(x+'<br>');
}

var myArray = ['a','b','c'];

// Find c
output('Index of c: ' + ~myArray.indexOf('c'));

if(~myArray.indexOf('c')) {
	output('Found: c');
} else {
	output('Not found: c');
}

// Find d
output('Index of d: ' + ~myArray.indexOf('d'));

if(~myArray.indexOf('d')) {
	output('Found: d');
} else {
	output('Not found: d');
}