I'm navigating the world of coding, having just started a month ago, and I've hit a roadblock. I'm working on creating an autocomplete feature where I need to compare user input with a specific key-value pair from an array that contains multiple objects with various key-value pairs.
Here's what I have so far, but I'm encountering some difficulties.
The 'ingredients' array stores information about multiple objects.
$("#ingredientDetails").click(function () {
var searchQuery = $("input[type='text']").val();
for (var i = 0; i < ingredients.length; i++) {
if (searchQuery === Object.key(ingredients)) {
console.log("matching");
} else {
console.log("not matching");
}
}
});