Skip to content

Nikolaos Litsas#94

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

Nikolaos Litsas#94
litsas7 wants to merge 2 commits intoboolean-uk:mainfrom
litsas7:main

Conversation

@litsas7
Copy link

@litsas7 litsas7 commented Jan 10, 2024

Core

} 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