Week 2
camelCase
Walk the letters. A capital letter starts a new word.
A name written in camel case.
The same name with underscores.
The question, more slowly
The question is: a name in camel case comes in, like preferredFirstName, and you print the same name in snake case, preferred_first_name. The first word stays lowercase. Each later capital starts a new word and becomes an underscore plus a lowercase letter.
Walk the characters. Letters that are already lowercase are copied. A capital is a boundary. You can assume the input really is camel case, so you do not have to handle spaces or punctuation.
People insert an underscore before the first letter, or they lowercase the whole string first and then cannot see where the words were. Mark the capitals on paper before you write the loop.
Before you code
Write preferredFirstName on paper and mark every capital before you touch the keyboard.