Strings

Pad Text

Pad Text

padStart adds characters to the front of a string until it reaches a target length. It is useful for IDs that need a consistent width.

Your task: Write formatInvoice. It should return INV- followed by the invoice number padded to four digits.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Pad Text

padStart adds characters to the front of a string until it reaches a target length. It is useful for IDs that need a consistent width.

Your task: Write formatInvoice. It should return INV- followed by the invoice number padded to four digits.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.