I am finding it difficult getting country name in intl input

I am new to Jquery and I am not the author of this script I only modified it to fit my needs but it's not working in chrome but works in mozilla Firefox. please this is what i have tried bel ow.

const intlPhoneNumber = function (countryCode) {
  // get the country data from the plugin
  const countryData = $.fn.intlTelInput.getCountryData();
  const telInput = $("#phone-number");
  const telInputLabel = telInput.parents(".form-group").find("label");
  const countryDropdown = $("#phone-number-country");
  const phonePrefix = $(".phone-number-prefix");
  const fullPhoneNumber = $("#phone-number-full");
  const fullCountry = $("#country");
  const errorMsg = $("#error-msg");
  const initCountry = countryCode || 'us';
  let pattern = '';

  //set initial pattern for formatting
  if (initCountry === 'us') {
    pattern = '{{9999999999}}';
   } else {
    // using as temp until formatting on init figured out
    pattern = '{{9999999999}}';
  }

  // reset function to reset error state on validation
  const reset = function () {
    telInput.attr("placeholder", "Phone Number");
    telInput.removeClass("has-error");
    telInputLabel.removeClass("has-error");
    errorMsg.addClass("hidden-xs-up");
  };

  // populate the country dropdown with intl-tel-input countries data
  $.each(countryData, function (i, country) {
    countryDropdown.append($("<option></option>").attr("value", country.iso2).text(country.name));
  });



// init plugin for formatting placeholders
  telInput.intlTelInput({
    allowDropdown: false,
    initialCountry: initCountry,
    utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/8.5.0/js/utils.js" });


  // set dropdowns initial value
  const initialCountry = telInput.intlTelInput("getSelectedCountryData").iso2;
  let dialCode = telInput.intlTelInput("getSelectedCountryData").dialCode;
  countryDropdown.val(initialCountry);
  phonePrefix.text("+" + dialCode);
  //$("#country").val(telInput.intlTelInput("getSelectedCountryData").name);

  // init format
  telInput.formatter({
    'pattern': pattern });


  // delete intl-tel-input items that aren't needed
  $('.flag-container').remove();
  $('.intl-tel-input').replaceWith(function () {
    return $('#phone-number', this);
  });

  // set placeholder
  telInput.attr("placeholder", "Phone number");

  // on blur: validate
  telInput.blur(function () {
    // reset states
    reset();

    if ($.trim(telInput.val())) {
      // if number is not valid
      if (telInput.intlTelInput("isValidNumber")) {
        // set hidden input to dial code + inputted number
        //fullCountry.val(telInput.intlTelInput("getSelectedCountryData").name);
        fullPhoneNumber.val(telInput.intlTelInput("getSelectedCountryData").dialCode + telInput.val());
      } else {
        // set error states
        telInput.addClass("has-error");
        telInputLabel.addClass("has-error");
        errorMsg.removeClass("hidden-xs-up");
        //clear hidden input val
        fullPhoneNumber.val("");
      }
    }
  });

  // on keyup / change flag: reset
  telInput.on("keyup change", reset);
  // listen to the country dropdown for changes.
  // updates placeholder and prefix when changed
  countryDropdown.change(function () {
    // Update Placeholder via plugin - so we can get the example number + format
    telInput.intlTelInput("setCountry", $(this).val());
    // Update Dial Code Prefix
    dialCode = telInput.intlTelInput("getSelectedCountryData").dialCode;
    phonePrefix.text("+" + dialCode);
    // Use updated placeholder to define formatting pattern
    pattern = telInput.attr("placeholder").replace(new RegExp("[0-9]", "g"), "9").replace(/([9]\d{0,10})/g, '{{$1}}');
    // update formatter
    telInput.formatter().resetPattern(pattern);
    // clear telephone input to prevent validation errors
    telInput.val("");
    // update placeholder to specific
    telInput.attr("placeholder", "Phone Number");
    // $("#country").val(telInput.intlTelInput("getSelectedCountryData").name);
  });
  $("form").submit(countryData,function(i, country) {
    fullCountry.val(telInput.intlTelInput("getSelectedCountryData").name);
    fullPhoneNumber.val('+' + telInput.intlTelInput("getSelectedCountryData").dialCode + $("#phone-number").val());      
        });
};
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum