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

196
Views
Conditional (ternary) operator is going directly to else option

I am trying to make a conditional to choose a link according to the type of user I get from the sessionStorage, but it always goes directly to else. I can't find the error, and I don't know what else to try.

I´m using React, and the function Link is what I'm using as href for the

Thank you very much!

export default function IndexCards(props) {

let tipoUser = sessionStorage.getItem("TipoUser")
console.log(tipoUser, "Soy tipo user")

const linkPax = "https://test.com/pax_mockUp.html"
const linkRamp = "https://test.com/ramp_mockUp.html"
const linkLogin = "https://test.com/Login/"


function Link() {
    return tipoUser === 14 ? linkPax
         : tipoUser === 15 ? linkRamp
         : linkLogin
}


return (
    <Fragment>
        <a id="idRef" href={Link()}>
            <div className="div_container">
                <div className="div_container-superior">
                    <p>{props.data.Al}{props.data.FlNoOut}</p>
                    <p>{props.data.sAPT}</p>
                </div>
                <div className="div_container-inferior">
                    <div className='ckin_container_abre'>
                        <h5>ABRE CHECK-IN</h5>
                        <p>{props.data.STDOut.slice(10)}</p>
                    </div>
                    <div className='ckin_container_cierra'>
                        <h5>CIERRA CHECK-IN</h5>
                        <p>{props.data.STDOut.slice(10)}</p>
                    </div>
                </div>
            </div>
        </a>
    </Fragment>
);

}

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

0

let tipoUser = parseInt(sessionStorage.getItem("TipoUser"))
about 4 years ago · Juan Pablo Isaza Report

0

The issue might be because of the type of the tipoUser variable. This will work for you

let tipoUser = Number(sessionStorage.getItem("TipoUser"))
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!