Avatar of Eddie Shipman
Eddie Shipman
Flag for United States of America

asked on 

Determine if JSON Object contains a value

I am creating a JSON object like this:
    window.attendees              = {};
    window.attendees.eventcode    = "GEVENT";
    window.attendees.price        = 169;
    window.attendees.WaitingList  = "";
    window.attendees.participants = [];

Open in new window


and populating it like this:
  function addParticipant() {
    var participant = {};
    // want to check here if the email to be added already exists in window.attendees.participants
    var valid = $('#checkout-step-billing .voucher_form').validationEngine('validate');
    if (valid) {
      participant.firstname   = $('#firstname').val();
      participant.lastname    = $('#lastname').val();
      participant.DOB         = $('#DOB').val();
      participant.Last4       = $('#Last4SSN').val();
      participant.PID         = $('#customer_id').val();
      participant.Phone       = $('#Phone').val();
      participant.Employer    = $('#Employer').val();
      participant.Address     = $('#Address').val();
      participant.City        = $('#City').val();
      participant.State       = $('#State').val();
      participant.Zip         = $('#Zip').val();
      participant.email       = $('#SomeoneElseEmail').val();
  
      window.attendees.participants.push(participant);
    } // if (valid)
  } // function addParticipant()

Open in new window


I need to prevent the same email address from being added twice if it already exists in window.attendees.participants.
JavaScript

Avatar of undefined
Last Comment
leakim971

8/22/2022 - Mon