Problems › JavaScript › games
Count league points
A sports league awards 3 points for a win and 1 for a draw. Total the points earned.
- A win is worth 3 points.
- A draw is worth 1 point.
- Losses earn nothing.
leaguePoints(wins: int, draws: int) → int
Where you start
function leaguePoints(wins, draws) {
}
Worked examples
| Call | Result |
|---|---|
leaguePoints(3, 1) | 10 |
leaguePoints(0, 0) | 0 |
leaguePoints(1, 1) | 4 |
leaguePoints(5, 0) | 15 |
Hint
Multiply wins by three and add the draws.
Reference solution in JavaScript
function leaguePoints(wins, draws) {
return 3 * wins + draws;
}