AI Frontend · Exercise 4 of 4 Previous
Advanced
Hide Personal Data Before Sending
The route /api/chat echoes what it received. When #send is clicked, replace every email address in the text of #prompt with [email] before posting it, show what the route received in #sent, and show 1 email hidden (or N emails hidden) in #note.
If there is no email, #note must be empty and the text is sent unchanged. Use the regular expression /[\w.+-]+@[\w-]+(\.[\w-]+)+/g.
What Check tests
- A message with one email is sent with
[email]and the note says1 email hidden - Two emails are both hidden and the note says
2 emails hidden - Text without an email is sent unchanged and the note is empty
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.