// String Methods & Concatenation const firstName = 'Jean Claude'; const lastName = 'van Johnshon'; const age = 36; const str = 'Hello there my name is Gabor'; const tags = 'web development,web design,programming'; let val; // Concatenation val = firstName + ' ' + lastName; // Append val = 'James '; val += 'Cole'; val = 'Hello, my name is ' + firstName + ' and I am ' + age + ' years old.'; // Escaping //val = 'That's awesome, I can't wait'; val = 'That\'s awesome, I can\'t wait'; // Length val = firstName.length; // Concat val = firstName.concat(' ', lastName); // Change case val = firstName.toUpperCase(); val = firstName.toLowerCase(); val = firstName[3]; // indexOf() val = firstName.indexOf('e'); val = firstName.lastIndexOf('e'); // charAt() val = firstName.charAt('0'); //Get last character val = firstName.charAt(firstName.length - 1); // substring() val = firstName.substring(0, 4); // slice() val = firstName.slice(0, 4); val = firstName.slice(-3); // split() val = str.split(' '); val = tags.split(','); // replace() val = str.replace('Gabor', 'Scott'); // includes() val = str.includes('Hello'); console.log(val);
Leave a Reply