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

99
Views
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
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!