← all problems

maskAccountNumber 🌶️🌶️🌶️ Extra

Write a method that takes one String parameter, number, and returns it with every character except the last 4 replaced by an asterisk. You may assume number.length() is at least 4.

Challenge hint: you cannot build a String of asterisks with a loop yet instead, take a substring of a String literal that is already made entirely of asterisks and long enough for any input you will see.

For example:

maskAccountNumber("1234567890123456") returns "************3456"