Explore Strings

Strings

Let's explore strings!

Explore:

  1. What is a string and what is not a string?
  2. Concatenate more than two strings together with the + syntax and the .concat() method
  3. Explore the methods and properties with different variables.
  4. Explore the charAt method with different numbers.
  5. 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 strings
console.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 Concatenation
let strOne = 'hello';
let strTwo = 'world';
let stringConcatenation = strOne + strTwo;
console.log(stringConcatenation);
// String Properties & Methods
// Set Up
let yourNameVar = 'Stephanie';
console.log(yourNameVar);
// A few different properties and methods
console.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);