Next to the Nickname: text, add an embedded expression that will show the player’s nickname if they have one.
Use a ternary operator to check if nickname is not null. If the player has a nickname, display nickname otherwise display “N/A”.
// running tests
You should use a ternary operator to check if nickname is truthy.
If your ternary is truthy, it should display the player’s nickname.
If your ternary is falsy, it should display the string N/A.
// tests completed
I’m not sure where the error is coming from. Previous posts say I should strict compare in my ternary. I’ve reversed the order of truthy and falsey using === and removed the quotes in different places. Same error every time. The way I’ve written it is:
If the expression {nickname} does not strictly equal “null”, then it is truthy and should return the expression{nickname}. If it is falsey, then it should return “N/A”.
Am I reading the directions correctly?
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Challenge Information:
Learn Modern JavaScript Methods by Building Football Team Cards - Step 33
I do not think you need the brackets. You also do not need to specify this condition !== "null" the optional chaining ? catered for that, Also, you need to use this syntax ${} once to interpolate your strings.
You’re very close! Look at your h2 line for isCaptain.
Using ${} isn’t just for variables. It’s most commonly used with single variables, but its purpose is to tell the JavaScript compiler “Hey! I’m going to put some more JavaScript commands into the middle of this text!”
Just like the backtick (template literal) says, I’m going to do some text stuff here, the ${} says, I’m going to do some programming commands here.
// running tests
If your ternary is truthy, it should display the player’s nickname.
If your ternary is falsy, it should display the string N/A.
// tests completed