Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // You check if the char is not a letter OR not the $ symbol, you should be checking if it is not a letter AND not the $ symbol.
- // In other words change the || (OR) operator to && (AND) in your if statement like this:
- private String normalizeDiscountCode(String discountCode){
- for(char c : discountCode.toCharArray()){
- if(!Character.isLetter(c) && c != '$'){
- throw new IllegalArgumentException("Invalid discount code");
- }
- }
- return discountCode.toUpperCase();
- }
- // And you will be able to pass the challenge.
Advertisement
Add Comment
Please, Sign In to add comment