JSFiddle - React, Tailwind, and code Playground

by orolo

JavaScript

//i have a valid json object w/ a couple of hundred array objects like so:
var data = {[
            "6554" ,
            "FOO BAR" ,
            "5454 SOUTH 2121 WEST" ,
            "SALT LAKE CITY UT" ,
            "84202" 
]}
    
var selectedNames = ["FOO", "FOO BAR", "BAX"];


    
    



$(data.Customer_JSON).each(function(index, value) {
    var checkWord = value[1];
    var checkIndex = index;

    $(selectedNames).each(function(value) {
        if (checkWord === value) {
            //this part works; if it's in the selected names array it will log out
            console.log(checkWord + "==" + value);

            
            //this part doesn't work; i need the index of the checkWord object
            selectedNamesKeys.push(checkIndex);
        }
    });
    
    //this comes up blank (or i could get it to print numerically but not the correct index numbers
    console.log(selectedNamesKeys)

});