JSFiddle - React, Tailwind, and code Playground
by m4xout
HTML
<button onclick="myFunction()">Try it</button>
JavaScript
let myObject = {
name1: {
title: 'Mr',
options: ['A', 'B', 'C'],
},
name2: {
title: 'Mrs',
options: ['C', 'D', 'E'],
}
};
function myFunction() {
var optionSearch = prompt('What letter are you searching for?');
for(var i=0; i < myObject.length; i++) {
console.log(myObject[i]);
if (arr[i] == optionSearch)
console.log(arr[i] + ' is equal to optionSearch');
}}