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

201
Views
how to check i specific word exists in array of objects
my_arr = [
  { "keywords": "set,on,increease,decrease,low,medium,high,forward,backward", "commands": "SET" },
  { "keywords": "get,access,retrieve", "commands": "GET" },
  { "keywords": "run", "commands": "RUN" },
  { "keywords": "stop", "commands": "STOP" }
]

i want to find if increase exists in keywords?

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

0

What about something like this

const data = [
  { "keywords": "set,on,increase,decrease,low,medium,high,forward,backward", "commands": "SET" },
  { "keywords": "get,access,retrieve", "commands": "GET" },
  { "keywords": "run", "commands": "RUN" },
  { "keywords": "stop", "commands": "STOP" }
]


const keywordExists = keyword => data.flatMap(({keywords}) => keywords.split(',')).includes(keyword)


console.log(keywordExists('increase'))
console.log(keywordExists('decrease'))
console.log(keywordExists('not valid keyword'))

about 4 years ago · Juan Pablo Isaza Report

0

I think this must be work.

const keys = [
  { "keywords": "set,on,increease,decrease,low,medium,high,forward,backward", "commands": "SET" },
  { "keywords": "get,access,retrieve", "commands": "GET" },
  { "keywords": "run", "commands": "RUN" },
  { "keywords": "stop", "commands": "STOP" }
]

function check(value) {
    // On every value on keys get index
    for (let i in keys) {
        // Get key from keys with index value
        const key = keys[i];
        // Check if is matching
        if (key.keywords.split(',').includes(value))
            // If successfuly matching is found return commands value
            return key.commands;
    }
    // If any result doesnt returned, return null.
    return null;
}
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!