Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

How to compare given email value using JavaScript

(0) ShareShare
ReportReport
Posted on by 340

Hi Guys

I want to compare the given "to" email ID (e.g. test1@gmail.com) on Email form with set of two email ID's (e.g. test2@gmail.com && test3@gmail.com) . How can this be achieved using Javascript.

set 1 = "test2@gmail.com"," test3@gmail.com".

check in if condition

if(set1.has(test1@gamil.com)

{

}

else

{

}

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: How to compare given email value using JavaScript

    Hello Sandy Hello

    Your code should look like the below:

    let to = "test1@gmail.com";
    let text = "test2@gmail.com,test3@gmail.com";
    const myArray = text.split(",");
    for (let i = 0; i < myArray.length; i  ) {
      if(to === myArray[i]){
      console.log("Test");
      }
    } 

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp: 923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans