Reputation: 245
I know there must be a simple solution to this that I can't figure out.
I have an array of objects that contain these two values:
team.seed: number,
team.placement: string
team.placement
will either be a simple string like 7, indicating a team made 7th place. It can also be something like 10T
, meaning they tied for 10th
place.
I'm creating a table that should print out all the differences between the initial seed and the final placement:
<tr *ngFor='let team of team_array'>
<td>{{team.placement - team.seed}}</td>
</tr>
This works fine if placement does not have the trailing T, but prints a NaN
value if it does. How can I handle placement so that I can get a numerical value in each case?
Upvotes: 0
Views: 64
Reputation: 160
You can parse team.placement to number first,
try
paresInt(team.placement)
Upvotes: 2