daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Javascript Intro & Basics
  2.  
  3. ## 1. Variables
  4.  
  5. ``` JAVASCRIPT
  6.  
  7. // Variables
  8.  
  9. // CONST
  10. // How do I declare a const variable?
  11.  
  12. const myBirthday = '24th June 1991'
  13.  
  14. // LET
  15. // How do I declare a let variable?
  16.  
  17. let myAge = 27
  18.  
  19. ```
  20.  
  21. ## 2. Datatypes
  22.  
  23. ``` JAVASCRIPT
  24.  
  25. // Datatypes
  26.  
  27. let myName = "Matthew Cross"; // String
  28.  
  29. let myAge = 27; // Number
  30.  
  31. let myMaritalStatus = false; // Boolean
  32.  
  33. let myPets = ["Dog", "Rabbit", true, 12]; // Array
  34.  
  35. let myself = {
  36.   'name': 'Matthew',
  37.   'age': 27,
  38.   'married': false
  39.   'hobbies': ['Coding', 'More Coding', 'Coding Again']
  40. } // JSON / Object
  41.  
  42. ```
  43.  
  44. ## 3. Outputs
  45.  
  46. ``` JAVASCRIPT
  47.  
  48. document.write('<h1>Hello World</h1>')
  49. console.log('Hello World')
  50. alert('Hello World')
  51.  
  52. ```
  53.  
  54. ## 4. Functions
  55.  
  56. ``` JAVASCRIPT
  57.  
  58. // Functions
  59.  
  60. // Simple function without an argument or parameter
  61.  
  62. function sayHello(){
  63.     alert("Hello!");
  64.   };
  65.  
  66.   sayHello();
  67.  
  68. // Function that requires arguments or parameters to be passed in
  69.  
  70.   function introduceMyself(name, age, maritalStatus, pets){
  71.       document.write("<h1>About Me!</h1>");
  72.       document.write(`<h3>My Name is: ${name} </h3>`)
  73.       document.write("<h3>My Name is: " + name + "</h3>");
  74.       document.write("<h3>My Age is: " + age + "</h3>");
  75.       document.write("<h3>Am I married? " + maritalStatus + "</h3>");
  76.       document.write("<h3>My Favorite Pet is my: " + pets[1] + " " + pets[0] + "</h3>");
  77.     };
  78.    
  79.   introduceMyself(myName, myAge, myMaritalStatus, myPets);
  80.  
  81. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top