forked from airamez/codando-live
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_02_Intro.js
More file actions
51 lines (42 loc) · 1.25 KB
/
_02_Intro.js
File metadata and controls
51 lines (42 loc) · 1.25 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
//debugger; // Execution will pause here if DevTools is open
// Log
console.log('Hello World!');
console.log('Hello', 'World');
// Variables
let firstName = "Jose"; // String
console.log(firstName, typeof firstName);
let age = 25; // Number
console.log(age, typeof age);
let price = 19.99; // Number
console.log(price, typeof price);
let isStudent = true; // Boolean
console.log(isStudent, typeof isStudent);
let product = null; // null
console.log(product, typeof product);
// The same variable can receive different types
let mutantVar = "I am a string";
console.log(mutantVar, typeof mutantVar);
mutantVar = 10;
console.log(mutantVar, typeof mutantVar);
mutantVar = true;
console.log(mutantVar, typeof mutantVar);
// Read input from user
firstName = prompt("What is your name?");
console.log(`Hello ${firstName}!`);
// Showing data to the user
alert(`Hello, ${firstName}!`);
//Basic Operators
let n1 = 10;
let n2 = 3;
let result1 = n1 / n2; // 10 ÷ 3 ≈ 3.333...
console.log(result1);
let result2 = Math.floor(n1 / n2);
console.log(result2);
// Random number
let randomDecimal = Math.floor(Math.random() * 100);
console.log(randomDecimal);
// Only possible without: `"use strict";`
x = 10
console.log(x);
// NOTE: UNCOMMENT THE FIRST LIKE AND TRY