Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Get numbers of difference in two strings javascript

i have two string

const string1 = "usa(Country), with concealed(O), zipper(Closure)"
const string2 = "usa(Country), with(O), concealed zipper(Closure)"

I want to find diff in these two string for example in this scenario it is 2

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm presuming the strings need to be compared based on the comma separations, but to be fair there isn't enough details in the question...

Split the strings by comma

// split function will be an array of strings
const split = (str, delimiter) => str.split(delimiter)

Apply the above function to both strings, and compare the results

// this uses lodash
// result will be an array, get the length
const result = _.difference(split(string1, ','), split(string2, ',')

If you're not going to use lodash, you can look up the vanilla JS implementation of difference

If order is important, you may need _.xor, but you can determine that with testing

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!