zakkudesu
8/17/2019 - 8:53 AM

string methods

const firstName = 'Zach';
const lastName = 'Alcerro';
const age = 32;
const str = 'hello there my name is Zach'
const tags = 'web design,web development,sass'

let val;

val = firstName + ' ' + lastName;

val = 'Brad ';
val += 'Traversedom'

val = "Hello, my name is " + firstName + ' and I am ' + age + '.';

val = 'That\'s awesome, I can\'t wait';

val = firstName.length;

//string methods

//concat() 
val = firstName.concat(' ', lastName);

//toUpperCase() toLowerCase()
val = firstName.toUpperCase();

//indexof()
val = firstName.indexOf('c');

//charAt()
val = firstName.charAt(0);

//get last character
val = lastName.charAt(lastName.length - 1);

//substring()
val = firstName.substring(0,2);

//slice()
val = firstName.slice(0,3);
val = firstName.slice(-3);

//split()
val = str.split(' ');
val = tags.split(',');

//replace();
val = str.replace('Zach', 'Brad')

//includes();
val = str.includes('foo');


console.log(val);