Reputation: 1555
In my React code I have the following code in a span element.
<span>
slutdatum: {item.end}
- {week} veckor
</span>
I would like to change the text in my span element "veckor" if the value of {week} is larger then 1, else the text should be "vecka"
Could this be done with some sort of ternary condition? I am quite new to JavaScript and React.
Upvotes: 1
Views: 302
Reputation: 13588
You can render it conditionally like follows
<span>
slutdatum: {item.end}
- {week} {week > 1 ? 'veckor' : 'vecka' }
</span>
Upvotes: 2