Skip to content

Commit

Permalink
Change while loop condition to use validator function
Browse files Browse the repository at this point in the history
Clean up while loop conditions for simplification and clarity
  • Loading branch information
rik-rosseel authored Sep 17, 2022
1 parent 55e316e commit 68a5637
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions LaunchSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ function buildSmallWidget(widget) {
// Check for first launch that is to be determined, to be confirmed or is go for launch.
while (
firstLaunchIndex < data.results.length
&& data.results[firstLaunchIndex].status.id != 1
&& data.results[firstLaunchIndex].status.id != 2
&& data.results[firstLaunchIndex].status.id != 8
) {
&& !isValidStatus(data.results[firstLaunchIndex].status.id)
) {
firstLaunchIndex++;
}
// Text for the first upcoming luanch.
Expand All @@ -200,7 +198,7 @@ function buildSmallWidget(widget) {
widget.addSpacer(5);

// First launch status text.
const firstLaunchStatusText = statusStack.addText(data.results[firstLaunchIndex].status.abbrev);
const firstLaunchStatusText = statusStack.addText(data.results[firstLaunchIndex].status.abbrev);
firstLaunchStatusText.textColor = BGColor;
firstLaunchStatusText.font = statusFont;

Expand Down Expand Up @@ -230,10 +228,8 @@ function buildMediumWidget(widget) {
// Check for first launch that is to be determined, to be confirmed or is go for launch.
while (
firstLaunchIndex < data.results.length
&& data.results[firstLaunchIndex].status.id != 1
&& data.results[firstLaunchIndex].status.id != 2
&& data.results[firstLaunchIndex].status.id != 8
) {
&& !isValidStatus(data.results[firstLaunchIndex].status.id)
) {
firstLaunchIndex++;
}
// Text for the first upcoming luanch.
Expand Down

0 comments on commit 68a5637

Please sign in to comment.