Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
How to check if some object values contains some string in array of strings in JavaScript

I'm working on a simple translate option, but I'm stuck in case when I have duplicated titles. When titles are different it's working fine, but when I have duplicates it doesn't translate them.

Here is the function:

function Translate(language, availableLanguages) {
    let titles = [...document.getElementsByClassName('translate')]
    let titlesValues = []

    titles.forEach((title) => {
        titlesValues.push(title.textContent)
    })

    for (let i = 0; i < availableLanguages.length; i++) {
        const languageObject = availableLanguages[i];
        
        titlesValues.forEach((title) => {
            if(Object.values(languageObject).includes(title)) {
                titles[titlesValues.indexOf(title)].textContent = languageObject[language]
            }
        })
    }
}

Here is the incoming languages json:

{
    "Languages": [
        "English",
        "German"
    ]
}

Here is the availableLanguages json:

[
    {
        "Key": "Hello",
        "English": "Hello",
        "German": "Hallo"
    }
]
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda