0

This is my picture

Hello, my array is given in the picture from which I want to find the unique value. Like ['round', 'marquees', 'princess', 'oval']

var array = [];

$.each(storeKeyValue, function (index, diamond) {
    if (index == "shape") {
        // console.log(diamond)
        array.push(diamond);
        $(".shapes").append('<option value="' + diamond + '">' + diamond + "</option>");
    } else if (index == "color") {
        // console.log(diamond)
        $(".colors").append('<option value="' + diamond + '">' + diamond + "</option>");
    } else if (index == "quality") {
        // console.log(diamond)
        $(".quality").append('<option value="' + diamond + '">' + diamond + "</option>");
    }
});

console.log(array);

$(document).ready(function () {
    $(document).on("change", ".shapes", function (e) {
        var shape = $(this).val();
        if (storeKeyValue.shape === shape) {
            $.each(storeKeyValue, function (index, size) {
                if (index == "size") {
                    $(this).siblings(".size_diamond").empty();
                    $(".size").append('<option value="' + size + '">' + size + "</option>");
                }
            });
        }
    });
});
Vijay Hardaha
  • 2,411
  • 1
  • 7
  • 16
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Sep 27 '22 at 06:41
  • Does this solve your problem? https://stackoverflow.com/questions/1960473/get-all-unique-values-in-a-javascript-array-remove-duplicates – marcobiedermann Sep 27 '22 at 07:25

0 Answers0