Strings Flashcards
Define a string called ‘statement’ with the text of - She said “How’s the family?”
var statement = “She said "How’s the family?"”;
Set the ‘escapedNewLine’ variable to the string of a new line character.
var escapedNewLine = “\n”;
Set the ‘escapedBackslash’ variable to the string of a backslash character.
var escapedBackslash = “\”;
Set the ‘escapedTab’ variable to the string of a tab character.
var escapedTab = “\t”;
What will the following console.log statement output?
var first_name = "Jim"; var last_name = "Hoskins";
console.log(first_name + last_name);
JimHoskins
What will the following console.log statement output?
var myMultilineVar = “Line one\n” +
“Line two\n” +
“Line three”;
console.log(myMultilineVar);
on the first line “Line one”, the second “Line two”, and on the final line “Line three”
What will the following console.log statement output?
var first_name = "Jim"; var last_name = "Hoskins";
console.log(first_name + “ “ + last_name);
Jim Hoskins
Backslash purpose
escapes the character
var quick = “The quick brown fox jumps over the lazy dog”;
Create a variable of ‘quickLength’, to assign the length of the string ‘quick’.
var quickLength = quick.length;
var quick = “The quick brown fox jumps over the lazy dog”;
Create a variable of ‘indexOfBrown’, to find the index of the string of “brown” in the string ‘quick’.
var indexOfBrown = quick.indexOf(“brown”);
var quick = “The quick brown fox jumps over the lazy dog”;
Create a variable of ‘tenthCharacter’, to get the tenth character of the string ‘quick’.
var tenthCharacter = quick.charAt(9);
var quick = “The quick brown fox jumps over the lazy dog”;
Create a variable of ‘wordBrown’, to extract the substring of “brown” from the string ‘quick’.
var wordBrown = quick.substr(10, 5);
var quick = “The quick brown fox jumps over the lazy dog”;
Create a variable of ‘quickUpper’, to the uppercased version of the string ‘quick’.
var quickUpper = quick.toUpperCase();
var quick = “The quick brown fox jumps over the lazy dog”;
Create a variable of ‘quickLower’, to the lowercased version of the string ‘quick’.
var quickLower = quick.toLowerCase();
== vs. ===
== ---> value === ---> type and value