I'm using a jQuery.Each() function to iterate over an Object fetched through an API. (Woocommerce API). Meta_data is being published in the object with value and key parameters.
I would like to the the value of the part where the key is _cpo_cart_weight. I can get this by using a numeric value like meta_data[6].value, but i prefer to get it by the key name. How can I do this?
Second question. Later in this object, line_items are being given. Can I iterate through these by using a second $.each function?
Answer (given by editor)
console.log(meta_data.find(item => item.key==="_cpo_cart_weight").value)<script>
const meta_data = [{
    "id": 2036,
    "key": "is_vat_exempt",
    "value": "no"
  },
  {
    "id": 2037,
    "key": "_iconic_wds_is_same_day",
    "value": ""
  },
  {
    "id": 2038,
    "key": "_iconic_wds_is_next_day",
    "value": ""
  },
  {
    "id": 2039,
    "key": "jckwds_date",
    "value": "20/12/2021"
  },
  {
    "id": 2040,
    "key": "jckwds_date_ymd",
    "value": "20211220"
  },
  {
    "id": 2041,
    "key": "jckwds_timestamp",
    "value": "1639990800"
  },
  {
    "id": 2042,
    "key": "_cpo_cart_weight",
    "value": "0.5"
  },
  {
    "id": 2043,
    "key": "_woofunnel_cid",
    "value": "1"
  },
  {
    "id": 2047,
    "key": "_new_order_email_sent",
    "value": "true"
  },
  {
    "id": 2048,
    "key": "_wfacp_report_needs_normalization",
    "value": "yes"
  }
];
</script> 
    