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

214
Vistas
If statement in Jsx render based on data

Whats simplest way to write a if statement in jsx when its based on data your receiving

how can i check the other code at the same time-if that makes sense? so if its not "P" then i want to make sure the other value is deffo a "L"?

code = P so output “Walking” code = L so output "Running"

    text={
if(exercise.code = P)
{ "Walking"} 
else (exercise.code = L) 
{"Running"}} 
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

{
  exercise?.code === "P" ? "Walking" : exercise?.code === "L" ? "Running" 
  : null 
}

Here {} means you are in JS and can write if conditions. ? : is ternary operator.

about 4 years ago · Juan Pablo Isaza Denunciar

0

{ exercise.code === "P" ? "Walking" : "Running" }
about 4 years ago · Juan Pablo Isaza Denunciar

0

Create an object to use as a mapping:

const codeMap = {
  C: "Crawling",
  P: "Walking",
  L: "Running"
};

Then you can perform a lookup in your JSX:

... { codeMap[excercise?.code] || "Unknown/missing code" } ...

That will allow you to have as many codes as you want, and the JSX will not have to be changed.

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