You almost got it. There are some errors though:
- you’re not iterating over all the chars of the password (
i < password.length() - 1
is wrong) - you start with a digit count of 1 instead of 0
- you make the check that the count of digits is at least 2 as soon as you meet the first digit, instead of checking it after you have scanned all the characters