JavaScript Challenge: Format a Phone Number 📱 | freeCodeCamp Daily Coding

Опубликовано: 29 Апрель 2026
на канале: CodeCraft Academy
54
1

In today’s freeCodeCamp Daily Coding Challenge, we’ll solve a classic string manipulation problem in JavaScript:

👉 Given a string of 10 digits, return it formatted as a phone number in the style:
+D (DDD) DDD-DDDD
You’ll learn:

How to use regex for input validation

How to slice strings to extract parts

How to build formatted strings with template literals

Why normalization (String(number).trim()) is important

This challenge is perfect for sharpening your JavaScript fundamentals and preparing for coding interviews. 🚀