Advertisement
JPDG13

Java Intro Tutorial Part 1

Apr 7th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. alert('hello world');
  2. console.error('this is an error');
  3. console.warn('this is a warning');
  4. console.log('Hello world');
  5.  
  6. // Variables: var, let and, const.  Mainly use let and const
  7. // as var is a global variable
  8.  
  9. let age = 30;
  10.  age = 35;
  11. console.log('My age is ' + age);
  12.  
  13. // Use const unless you know you'll be reassigning something, like a score.
  14.  
  15. //Data Types: Strings, numbers, boolean, null, undefined, symbol
  16.  
  17. const name = 'Jason';
  18. const myAge = 41;
  19. const isCool = true;
  20. const rating = 4.5;
  21. const x = null; // this means it's empty, a variable with nothing in it
  22. const y = undefined;
  23. let z; //this is also undefined.
  24.  
  25. console.log(typeof name);
  26. console.log(typeof myAge);
  27. console.log(typeof isCool);
  28. console.log(typeof rating);
  29. console.log(typeof x);
  30. console.log(typeof y);
  31. console.log(typeof z);
  32.  
  33. //Concatenation
  34. console.log('My name is ' + name + ' and I am ' + age);
  35.  
  36. //Template... uses backticks, not single quotes
  37. const hello = (`My name is ${name} and I am ${age}`);
  38. console.log(hello);
  39.  
  40. const s = 'Hello World!';
  41. console.log(s.length);
  42. console.log(s.toUpperCase()); //makes s uppercase
  43. console.log(s.toLowerCase());
  44. console.log(s.substring(0,5).toUpperCase()); // only prints first five letters
  45.  
  46. const t = 'tech, computers, it, code'
  47. console.log(t.split(', ')); //splits t into an array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement