Setting strings to variables
Use the length property to find the length of a certain string.
strLength.length :
let autos = "Honda, Ford, GMC";
Using autos.slice(14,17) :
Using autos.slice(7) :
Using autos.slice(-6) :
JavaScript starts counting positions at 0.
substring() cannot accept negative indexes and is similar to slice().
let food = "tacos, nachos, burritos";
Using food.substring(8,14) :
substr() similar to slice(), now the second parameter specifies the length of the string extracted.
You can also use negative numbers to start counting from right to left.
let gems = "ruby, emerald, sapphire";
Using gems.substr(6,7) :
Use replace() to replace a specific value with another value inside a string.
let welcome = "Hello, welcome to my page";
Now use 'let newWelcome = text.replace("Hello","Howdy");' :
replace() will only change the first match in the string. If you had two 'Hello' it would change only the first one.
replace() is also CaseSensitive, to make it case insensitive use '/i'.
Example: let newWelcome = text.replace(/HELLO/i,"Howdy");
Use either toUpperCase() to make the string all capitals OR use toLowerCase() to make the string all lower case.
let yell1 = "i'm king of the world!!";
let yell2 = yell1.toUpperCase();:
let whisper1 = "I'M KING OF THE WORLD!!";
let whisper2 = whisper1.toLowerCase();:
concat() just joins two or more strings.
let fName = "Itachi";
let lName = "Uchiha";
let fullName = fName.concat(" ",lName);:
You could also do 'let fullName = (fName+" "+lName)' and it will have the same output.
indexOf() returns the index (position) where it first found the specified text in a string.
let rhyme = 'Twinkle Twinkle Little Star';
rhyme.indexOf("Twinkle") :
lastIndexOf() returns the index (position) of where the specified string was found last.
let rhyme = 'Twinkle Twinkle Little Star';
rhyme.lastIndexOf("Twinkle") :
If neither can find the specified string index it will return a -1.
Both can also have a second parameter ("Twinkle", 8){-->left-to-right} to have a starting point in the index. Returns: 1
If we use a second parameter for lastIndexOf() it will be searching backwards.("Twinkle", 21){<--right-to-left} Returns: 12
Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document. To make your document look prfrickofessionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. Themes and styles also help keep your document coordinated. When you click Design and choose a new Theme, the pictures, charts, and SmartArt graphics change to match your new theme. When you apply styles, your headings change to match the new theme. Save time in Word with new buttons that show up where you need them. To change the way a picture fits in your document, click it and a button for layout options appears next to it. When you work on a table, click where you want to add a row or a column, and then click the plus sign. Reading is easier, too, in the new Reading view. You can collapse parts of the document and focus on the text you want. If you need to stop reading before you reach the end, Word remembers where you left off - even on another device. Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document. To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar.