Move Capital Letters to the Front

Published by Helen Yu in

Create a function that moves all capital letters to the front of a word.

Examples

capToFront("hApPy") ➞ "APhpy"

capToFront("moveMENT") ➞ "MENTmove"

capToFront("shOrtCAKE") ➞ "OCAKEshrt"

Notes

Keep the original relative order of the upper and lower case letters the same.

Watch a quick demo on how Edabit works.