Skip to content

Commit

Permalink
replace multiple ifs with one switch
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 committed Dec 23, 2024
1 parent 1db8e05 commit 46643b3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions frontend/cypress/support/helper/scoringSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ function checkVisibilityOfScoringComponent(isOverview: boolean, displayProperty:
}

function colorFromPercentage(percentage: number) {
if (percentage >= 100) {
return 'rgba(0, 0, 0, 0)';
}
if (percentage > 70) {
return 'rgb(30, 138, 41)';
}
if (percentage > 30) {
return 'rgb(255, 214, 0)';
switch (true) {
case percentage >= 100:
return 'rgba(0, 0, 0, 0)';
case percentage > 70:
return 'rgb(30, 138, 41)';
case percentage > 30:
return 'rgb(255, 214, 0)';
default:
return 'rgb(186, 56, 56)';
}
return 'rgb(186, 56, 56)';
}

function scoringValueFromPercentage(percentage: number): ScoringValue {
Expand Down

0 comments on commit 46643b3

Please sign in to comment.