Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda