JSFiddle - React, Tailwind, and code Playground

by alirokni

HTML

<script>
    var allVariants = {

        "T973467": [{
            "color": "T973467_Black Pink",

                "size2": "T973467_6_waist",

                "skuId": "92386760",
                "skuUpcCode": "669322854762",
                "inventoryStatus": "true",
                "SkuSalePrice": "",
                "SkuRegularPrice": "$44.00",
                "IsSuppressed": "false",
                "salePriceLabel": "now",
                "regularPriceLabel": "original",
                "surchargeFee": "0.0"
        }, {
            "color": "T973467_Black Pink",

                "size2": "T973467_8_waist",

                "skuId": "92386761",
                "skuUpcCode": "669322854779",
                "inventoryStatus": "true",
                "SkuSalePrice": "",
                "SkuRegularPrice": "$44.00",
                "IsSuppressed": "false",
                "salePriceLabel": "now",
                "regularPriceLabel": "original",
                "surchargeFee": "0.0"
        }, {
            "color": "T973467_Black Pink",

                "size2": "T973467_10_waist",

                "skuId": "92386762",
                "skuUpcCode": "669322854786",
                "inventoryStatus": "true",
                "SkuSalePrice": "",
                "SkuRegularPrice": "$44.00",
                "IsSuppressed": "false",
                "salePriceLabel": "now",
                "regularPriceLabel": "original",
                "surchargeFee": "0.0"
        }, {
            "color": "T973467_Black Pink",

                "size2": "T973467_12_waist",

                "skuId": "92386763",
                "skuUpcCode": "669322857374",
                "inventoryStatus": "true",
                "SkuSalePrice": "",
                "SkuRegularPrice": "$44.00",
                "IsSuppressed": "false",
                "salePriceLabel": "now",
                "regularPriceLabel": "original",
                "surchargeFee": "0.0"
        }, {
            "color":...

JavaScript

$('#msg').on('click', postDataToPB);

		function postDataToPB() {
		    var size = 0,
		        itemSize = 0,
		        allItems = {},
		        key, keys, me;
		    for (key in allVariants) {
		        if (allVariants.hasOwnProperty(key)) {
		            size++;
		            console.log(key);
		            for (keys in allVariants[key]) {
		                itemSize++;
		                allItems[keys] = allVariants[key][keys];
		                if (allVariants[key][keys].skuId == '92369651') {
		                    allItems[keys] = allVariants[key][keys].skuId + " selected";
		                    me = allVariants[key][keys].skuId;
		                } else {
		                    allItems[keys] = allVariants[key][keys].skuId;
		                }
		                //console.log("  " + allItems[keys]);
		            }
		        }
		    }
		    alert(me);
		}
		//alert(me + "is here")
		//console.log("object includes: " +  allItems[0]);
		//console.log("size " + size) //4
		//console.log("itemSize " +  itemSize)  // 18