Learn to Code — For Free
Hi so I’m not exactly sure what I’m doing wrong in this section.
“Right next to the ${name} expression, add a new embedded expression. Inside that expression, use a ternary operator to check if isCaptain is true. If so, return (Captain) otherwise returns an empty string.”
Here is my Code so Far:
playerCards.innerHTML += arr.map(
({ name, position, number, isCaptain, nickname }) => {
`
<div class="player-card">
<h2>${name}, ${(isCaptain == true) ? " (Captain)" : ""}</h2>,
</div>
`;
}
);
thank you once again for helping.
ILM
December 27, 2023, 4:39pm
2
please give the link to the step
ILM
December 27, 2023, 4:41pm
4
you should not have a comma after the name, and there shouldn’t be a space before (Captain)
1 Like
it is still giving me the same error of having a ternary operator to check if isCaptain is true
this is how i changed it
<h2>${name} ${(isCaptain == true)?"(Captain)" : ""}</h2>
ILM
December 27, 2023, 4:45pm
6
you still have a space before (Captain)
, meaning that if isCaptain
is true
you have two spaces after the name, when you should have only one
ILM
December 27, 2023, 4:46pm
7
an other possibility is that you should have only isCaptain
as condition, and not have a comparison, as isCaptain
is already a boolean
I’m sorry but I don’t see where my space is before (Captain), but I did change the isCaptain Boolean statement.
<h2>${name} ${(isCaptain)?'(Captain)':''}</h2>
It seems like I just didn’t need the parenthesis around the (isCaptain). Thank you for helping though. because when I submitted after taking out the parenthesis it worked out.
2 Likes
bro this code has given me headache
1 Like
ILM
January 14, 2024, 7:26pm
11
coding is hard! If you need help I suggest opening your own topic!
its ok boss, am sorry if I offended you in anyway. I just had parenthesis around (isCaptain) too. But thanks
ILM
February 2, 2024, 1:39pm
14
@parallelofleo ,
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
This step is kinda broken because I see in the player cards that (Captain) is before the name yet it only accepts this as like this:
solution redacted
an issue was created here to update the step so the word captain goes before the name
opened 11:18PM - 04 Apr 24 UTC
type: bug
help wanted
scope: curriculum
new javascript course
### Describe the Issue
A camper on the forum brought up a good point here
http… s://forum.freecodecamp.org/t/learn-modern-javascript-by-building-football-team-cards-step-30/658878/15?u=jwilkins.oboe
In the HTML markup, if the player is a captain, then the word captain shows up before their name
<img width="402" alt="Screenshot 2024-04-04 at 4 07 39 PM" src="https://github.com/freeCodeCamp/freeCodeCamp/assets/67210629/e15089a7-c361-487f-baa6-36334ac2a6fd">
however, in step 29, we are asking for the captain to be after their name
```js
<h2>${name} ${isCaptain ? "(Captain)" : ''}</h2>
```
so the description, and tests for this step needs to change so the ternary goes before the name
this should be the new answer
```js
<h2>${isCaptain ? "(Captain)" : ''} ${name}</h2>
```
here is the updated text
```md
Before the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string.
```
### Affected Page
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-modern-javascript-methods-by-building-football-team-cards/step-29
### Your code
see explanation above
### Expected behavior
see explanation above
### Screenshots
_No response_
### System
- Device: [e.g. iPhone 6, Laptop]
- OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
### Additional context
_No response_
Glen2
May 1, 2024, 1:09pm
17
First: re read the Question then look at your code
Second : Question ? ifTrue : ifFalse
hope this helps.
system
Closed
October 31, 2024, 1:09am
18
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.