-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (30 loc) · 795 Bytes
/
Copy pathindex.js
File metadata and controls
38 lines (30 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// How to create a constant in JS
const interestRate = 0.3;
// General variable
let theName = "James"; // String Literal
let age = 30; // Number Literal
let isApproved = false; // Boolean Literal
let firstName = undefined;
let lastName = null;
// Creating first object
let person = {
firstName: "Mosh",
age: 40,
};
// Dot notation
person.firstName = "John";
// Bracket Notation, benifits is, it allows for variables as inputs, so it can be decided at run time
let selection = "firstName";
person[selection] = "Mary";
// Arrays
let selectedColours = ["red", "blue"];
selectedColours[2] = 35;
// Functions
function greet(inputName) {
console.log("Hello " + inputName);
}
function square(inputNumber) {
output = inputNumber * inputNumber;
return output;
}
console.log(square(3));