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

150
Views
How to add a style to specific characters in Mapped/filtered object in react?

I have a json object which I have filtered and mapped. However, I need to add a background color to any item that has "Miss" or "Ms" or "Mrs". I am using tailwindcss right now but I know I can do inline styling.

I tried using the if else condition with a .match but it just makes the screen go blank, is there another way?

This is what I have so far

The api i am calling - https://randomuser.me/api/?results=20

const [searchUser, setSearchUser] = useState("")

 <div className="grid grid-cols-4 gap-2 p-2 mt-20">
        {data?.results.filter((val: any)=>{
          if (searchUser === "") {
            return val
          } else if (val.name.first.toLowerCase().includes(searchUser.toLowerCase())) { 
              return val          
          } else if (val.email.toLowerCase().includes(searchUser.toLowerCase())){
            return val
          } else if 
            (val.location.city.toLowerCase().includes(searchUser.toLowerCase())){
              return val
            } 
        }).map((d: any) => (
              
          <div className="border-4">
            <img src={d.picture.medium} />
            <p>
              {" "}
              {d.name.title} {d.name.first} {d.name.last}
            </p>
            <p className="font-bold text-lg font-serif">Gender: {d.gender}</p>
            <p className="font-bold text-lg font-serif">Contact: {d.email}</p>
            <p className="font-bold text-lg font-serif">
              City: {d.location.city}
            </p>
          </div>
        ))}
      </div>

Let me know, thank you.

about 4 years ago · Juan Pablo Isaza
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!