|
1 | 1 | /*
|
2 | 2 | === String Built in Methods ===
|
3 | 3 | */
|
4 |
| -let firstName = "Asabeneh"; |
5 |
| -let lastName = "Yetayeh"; |
6 |
| -let location = "Helsinki"; |
| 4 | +let firstName = 'Asabeneh'; |
| 5 | +let lastName = 'Yetayeh'; |
| 6 | +let location = 'Helsinki'; |
7 | 7 | console.log(firstName.length); // to check the length of a string
|
8 | 8 | console.log(firstName.toUpperCase()); // to capitalize
|
9 | 9 | console.log(firstName.toLowerCase()); // to change to lower case letters
|
10 | 10 |
|
11 |
| -let company = 'google' |
| 11 | +let company = 'google'; |
12 | 12 |
|
13 | 13 | var firstLetter = company.slice(0, 1); // to slice out the first letter of the word
|
14 | 14 | var remainingLetters = company.slice(1, company.length);
|
15 | 15 | console.log(firstLetter);
|
16 | 16 | console.log(remainingLetters);
|
17 | 17 | var modifiedName = firstLetter.toUpperCase() + remainingLetters;
|
18 | 18 | console.log(modifiedName);
|
19 |
| -var school = "International Academy Award"; |
| 19 | +var school = 'International Academy Award'; |
20 | 20 | console.log(school.split()); // creates an array of one item
|
21 |
| -console.log(school.split("")); // it creates an array of letters and spaces; |
22 |
| -console.log(school.split(" ")); // creates an array of words |
23 |
| -console.log(school.indexOf("A")); // gives the index of the A in the string which is case sensitive |
24 |
| -console.log(school.lastIndexOf("A")); //the last A, which is A from the word Award |
25 |
| -console.log(school.includes("rify")); // it checks if the string exist and returns boolean |
26 |
| -console.log(school.includes("Award")); // it checks if the string exist and returns boolean |
27 |
| -console.log(school.includes("demy")); // it checks if the string exist and returns boolean |
28 |
| -console.log(school.startsWith("Inter")); // checks if the string starts with the provided value and returns boolean |
| 21 | +console.log(school.split('')); // it creates an array of letters and spaces; |
| 22 | +console.log(school.split(' ')); // creates an array of words |
| 23 | +console.log(school.indexOf('A')); // gives the index of the A in the string which is case sensitive |
| 24 | +console.log(school.lastIndexOf('A')); //the last A, which is A from the word Award |
| 25 | +console.log(school.includes('rify')); // it checks if the string exist and returns boolean |
| 26 | +console.log(school.includes('Award')); // it checks if the string exist and returns boolean |
| 27 | +console.log(school.includes('demy')); // it checks if the string exist and returns boolean |
| 28 | +console.log(school.startsWith('Inter')); // checks if the string starts with the provided value and returns boolean |
29 | 29 |
|
30 |
| -var modifiedSchool = school.split(" "); |
| 30 | +var modifiedSchool = school.split(' '); |
31 | 31 | console.log(modifiedSchool);
|
0 commit comments