Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Javascript Intro & Basics
- ## 1. Variables
- ``` JAVASCRIPT
- // Variables
- // CONST
- // How do I declare a const variable?
- const myBirthday = '24th June 1991'
- // LET
- // How do I declare a let variable?
- let myAge = 27
- ```
- ## 2. Datatypes
- ``` JAVASCRIPT
- // Datatypes
- let myName = "Matthew Cross"; // String
- let myAge = 27; // Number
- let myMaritalStatus = false; // Boolean
- let myPets = ["Dog", "Rabbit", true, 12]; // Array
- let myself = {
- 'name': 'Matthew',
- 'age': 27,
- 'married': false
- 'hobbies': ['Coding', 'More Coding', 'Coding Again']
- } // JSON / Object
- ```
- ## 3. Outputs
- ``` JAVASCRIPT
- document.write('<h1>Hello World</h1>')
- console.log('Hello World')
- alert('Hello World')
- ```
- ## 4. Functions
- ``` JAVASCRIPT
- // Functions
- // Simple function without an argument or parameter
- function sayHello(){
- alert("Hello!");
- };
- sayHello();
- // Function that requires arguments or parameters to be passed in
- function introduceMyself(name, age, maritalStatus, pets){
- document.write("<h1>About Me!</h1>");
- document.write(`<h3>My Name is: ${name} </h3>`)
- document.write("<h3>My Name is: " + name + "</h3>");
- document.write("<h3>My Age is: " + age + "</h3>");
- document.write("<h3>Am I married? " + maritalStatus + "</h3>");
- document.write("<h3>My Favorite Pet is my: " + pets[1] + " " + pets[0] + "</h3>");
- };
- introduceMyself(myName, myAge, myMaritalStatus, myPets);
- ```
Add Comment
Please, Sign In to add comment