Guest User

Untitled

a guest
May 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. const firstName = 'William';
  2. const lastName = 'Johnson';
  3. const age = 22;
  4. const str = 'testing';
  5. const tags = 'web devalopement, design';
  6.  
  7. let val;
  8.  
  9. // val = firstName + lastName;
  10.  
  11. // // Concatenation
  12. val = firstName + ' ' + lastName;
  13.  
  14. // // Append
  15. val = 'Brad ';
  16. val += 'Traversy';
  17.  
  18. val = 'Hello, my name is ' + firstName + ' and I am ' + age;
  19.  
  20. // // Escaping
  21. val = 'That\'s awesome, I can\'t wait';
  22.  
  23. // // Length
  24. val = firstName.length;
  25.  
  26. // // concat
  27. val = firstName.concat(' ', lastName);
  28.  
  29. // // Change case
  30. val = firstName.toUpperCase();
  31. val = firstName.toLowerCase();
  32.  
  33. val = firstName[0];
  34.  
  35. // indexOf()
  36. val = firstName.indexOf('l');
  37. val = firstName.lastIndexOf('l');
  38.  
  39. val = firstName.charAt('5');
  40.  
  41. val = firstName.charAt(firstName.length -1);
  42.  
  43. // substring()
  44. val = firstName.substring(0,4);
  45.  
  46. // slice()
  47. val = firstName.slice(0,4);
  48. val = firstName.slice(-3);
  49.  
  50. val = tags.split(',');
  51.  
  52. //replace
  53. val = str.replace('new name', 'testing');
  54.  
  55. // includes()
  56. val = str.includes('testing');
  57.  
  58. console.log(val);
Add Comment
Please, Sign In to add comment