Lessons 108 to 109 – Complete 2020 Web Development Bootcamp

Lesson 108 – Challenge: Changing Casing in Text

To change all the characters in a string to uppercase you can use the method – toUpperCase().

For example, this code will change every character in the string “Shane” to the uppercase characters “SHANE”.

var name = "Shane";

The method – toLowerCase() – will turn all of the upper case characters in a string to lower case characters.

The challenge set out in this lesson is to prompt the user to input their name and then give the user an alert which says “Hello Angela(or whatever name was input).” The alert has to show the first character of the name as capitalized no matter how it was input. So for example, if the name was input as “Angela”, “angela” or “ANGELA”, the alert should still say “Hello Angela.”

Lesson 109 – Challenge: Changing String Casing Solution

This is my solution:

var name = prompt("What is your name?");
var nameLowerCase = name.toLowerCase();
var firstLetter = nameLowerCase.slice(0, 1); 
var firstLetterCapital = firstLetter.toUpperCase();

alert("Hello " + firstLetterCapital + nameLowerCase.slice(1));