Skip to content

Petros Mylonas#96

Open
Pmylonas13 wants to merge 2 commits intoboolean-uk:mainfrom
Pmylonas13:main
Open

Petros Mylonas#96
Pmylonas13 wants to merge 2 commits intoboolean-uk:mainfrom
Pmylonas13:main

Conversation

@Pmylonas13
Copy link

No description provided.

return true;
} else {
return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite allot of repeated/uneeded code here. A more concise approach would be like the following:

public boolean stepFour(int num) {
    for (int i = 0; i < favouriteNumbers.length; i++) {
        if (favouriteNumbers[i] == num) {
            return true;  // Return true immediately if the number is found
        }
    }
    return false;  // Return false if the number is not found after checking the entire array
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants