Design comparison
SolutionDesign
Solution retrospective
Hi! I have some difficulties with adding a space after every 4 characters to card number in real time.
Community feedback
- @dannebrobPosted about 2 years ago
Hi @BekEsaly, nice to see your solution to the challenge. I saw your question about adding spaces on the front of the credit card. I found that this function worked for me, give it a try 🖖
function injectSpaces(str) { let groupsOf4 = []; for (let start = 0; start < str.length; start += 4) { let group = str.slice(start, start + 4); groupsOf4.push(group); } return groupsOf4.join(" "); }
Marked as helpful0@BekEsalyPosted about 2 years ago@dannebrob Hi, many thanks for sending me this solution. I will definitely try it!
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord