Menu
CoddyTech

Recap - Email Validator

Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 64 of 78.

challenge icon

Challenge

Medium

Write a function named clean_email_list that takes an array of email addresses, emails, and returns a new array with the valid ones, cleaned up.

  • Clean every address first: remove the spaces at its start and end, and convert it to lower case.
  • Then keep only the addresses that contain exactly one @, with at least one character before it and at least one after it.

Keep the original order. Use map() and filter(), and no loop.

For example, clean_email_list(["Test@EXAMPLE.com", " invalid.email", " space@email.com "]) returns ["test@example.com", "space@email.com"].

The tests call clean_email_list() themselves. Do not call it, and do not print anything.

Try it yourself

func clean_email_list(emails: Array[String]):
	# Clean the addresses with map(), then keep the valid ones with filter()
	pass

All lessons in Logic & Flow

Practice on your own: Online GDScript compiler