Is there a better way to do this than a giant conditional operator (JS)?

  Kiến thức lập trình

Currently there is no bugs or any bad issues going on with this, but everytime I try to add new data to it then it does break.
It also looks very messy.
Is there any better way to do this?

(
                                                                    s==="FFP"?o.ffp:(
                                        s==='XP'? (await getXP(index,true))||o.e.xpLvl*o.e.xp:(
                                            s==="FSC"?o.fsc:(
                                                s==='BGP'?o.bgp:(
                                                    s=== "BTN"?btns[index]||0:(
                                                        s==='CIV'?await getCiv(index)||0:(
                                                            s==="TIQ"?await getTotalInv(index)||0:(
                                                                s==='IS1'?isold[index]||0:(
                                                                    s==="ITO"?acn[index].cache.itemsObtained||0:(
                                                                        s==='FLW'?flws[index]||0:(
                                                                            s==="PLY"?acn[index].playtime||0:(   
                                                                                s==="QSC"?(qusc[index]?qusc[index].completed:0):(
                                                                                    s==='QSR'?(qusc[index]?qusc[index].rankings:0):(
                                                                                        s==="DXP"?(dbs.xp[index]||0):(
                                                                                            s==='FPS'?etcscores.fps[index]||0:(
                                                                                                s==='SMN'?(index ==="admin_907"?1:0):
                                                                                                "N/A")
                                                                                      )
                                                                                  )
                                                                              )
                                                                          )
                                                                      )
                                                                  )
                                                              )
                                                          )
                                                      )
                                                  )
                                              )
                                          )
                                      )
                                    )
                              )

I’ve tried if/then/else statements but it’s literally the same messy thing although breaks a bit less often.

New contributor

doctorpepper126 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT