Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140161

Converting Ternary Operator to if / else statements

$
0
0

I found a fix for my application, but I copied and pasted the code, which doesn't match with the rest of the code, I want to turn these ternary operators into if/else statements.

const name = persona ? persona.player_name : steamID.getSteamID64();

I tried to do:

const name = persona;
if (name = persona) {
    persona.player_name;
} else {
    steamID.getSteamID64;
}

But it didn't work, any help will be appreciate it thanks!


Viewing all articles
Browse latest Browse all 140161

Trending Articles