Explore Strings
Strings
Let's explore strings!
Explore:
- What is a string and what is not a string?
- Concatenate more than two strings together with the
+
syntax and the.concat()
method - Explore the methods and properties with different variables.
- Explore the
charAt
method with different numbers. - Medium Difficulty: Fix the code
console.log('Let's print this string!');
to print Let's print this string! without an error.
console.log(typeof "a string of charactersssss");let aVariableReferencingAString = 'I hope you are having a wonderful day!';// These all print stringsconsole.log(aVariableReferencingAString);console.log("a string of charactersssss");console.log('b');console.log('8');console.log('true');console.log("'You miss one hundred percent of the shots you don't take.' - Wayne Gretzky");// What error occurs here?// Uncomment the code by deleting the two slashes in the line of code below://console.log('Let's print this string!');// Escaped Characters// How many backslashes are here?console.log('\\');console.log("What happens with a \n in the middle of a sentence?");//String Concatenationlet strOne = 'hello';let strTwo = 'world';let stringConcatenation = strOne + strTwo;console.log(stringConcatenation);// String Properties & Methods// Set Uplet yourNameVar = 'Stephanie';console.log(yourNameVar);// A few different properties and methodsconsole.log(yourNameVar.length);console.log(yourNameVar.charAt(0));console.log(yourNameVar.toUpperCase());console.log(yourNameVar.toLowerCase());console.log(yourNameVar);let stringOne = 'hello';let stringTwo = 'world';let stringConcatenationASecondWay = stringOne.concat(stringTwo);console.log(stringConcatenationASecondWay);