Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const firstName = 'William';
- const lastName = 'Johnson';
- const age = 22;
- const str = 'testing';
- const tags = 'web devalopement, design';
- let val;
- // val = firstName + lastName;
- // // Concatenation
- val = firstName + ' ' + lastName;
- // // Append
- val = 'Brad ';
- val += 'Traversy';
- val = 'Hello, my name is ' + firstName + ' and I am ' + age;
- // // Escaping
- 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[0];
- // indexOf()
- val = firstName.indexOf('l');
- val = firstName.lastIndexOf('l');
- val = firstName.charAt('5');
- val = firstName.charAt(firstName.length -1);
- // substring()
- val = firstName.substring(0,4);
- // slice()
- val = firstName.slice(0,4);
- val = firstName.slice(-3);
- val = tags.split(',');
- //replace
- val = str.replace('new name', 'testing');
- // includes()
- val = str.includes('testing');
- console.log(val);
Add Comment
Please, Sign In to add comment