Skip to content

interest-is-interesting: years before reaching desired balance when targetBalance <= balance #1976

Open
@tomrijnbeek

Description

@tomrijnbeek

The "Interest is Interesting" currently does not have a test case for task 4 where the target balance has been met by the balance already. If you target savings is 1000, but your balance is already - say - 1200, I would expect the method to return "0": the target has already been met.

I have seen implementations using a do-while loop, which would return 1 at the very least, whereas a while loop would return 0. Both currently pass as tests.

I would propose to add two test cases: one where the target balance is equal to the balance, and where the target balance is less than the balance. Both of which should return 0. Furthermore, the instructions should probably clarify that this is expected behaviour (as a hint perhaps?)

Happy to create a PR for this, but wanted to check whether this is indeed the desired behaviour first. This particular task does not appear to be present in other tracks that have the interest-is-interesting exercise, so I did not have any comparison material.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions