-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
Β·135 lines (128 loc) Β· 3.34 KB
/
index.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// let, const, var
let x = 10;
const personalId = 2525252; // ho
var mainAdd = "Berlin";
// strings
// 012345567910
let str = "This is a long.";
// bracket notions
console.log(str[10]);
// Escaping spatial characters ( \' , \" )
// New line (\n)
let strWithChr = "I'am \n Hi";
console.log(strWithChr);
// numbers
let y = 5;
console.log(x + y); // 10 + 5 = 15
let something;
console.log(something);
let float; //
float = 22.5; //
// typeof
console.log(typeof float);
console.log(typeof something);
console.log(typeof console);
// booleans
let bool = true;
console.log("bool = ", bool);
let check = 12 < 20;
console.log(1 == 100);
let str1 = "Hi ";
let str2 = "I am Hadi";
console.log("check =", check);
console.log(str1 + str2);
// conditions (===, !==, >=, <=, >, <)
// =
// ==
// ==
console.log(!bool);
let bool2 = false;
console.log(1 !== 1);
let che = 1 < 12;
console.log(che);
let age = 12;
let age2 = "12";
console.log(" value check == ", age == age2); // true
console.log(" value and type check === ", age === age2); // false
// ternary Operator
console.log(true ? "I like apple π" : "Hi cool I like pizza π");
console.log(1868677 < 100 ? "yeahhh" : "Noooo");
let varStr1 = "π";
let varStr2 = "π";
let resultStr = 1 < 55 ? varStr1 : varStr2;
console.log(resultStr);
// Js methods from Math(.max , .min , .floor , .ceil ,random )
console.log(Math.max(22, 3, 45, 555, -1)); // 6675
console.log(Math.min(1, 2, 455, 6675, 2, -1)); // -1
let num1 = 33.5;
console.log(Math.floor(num1)); //33
console.log(Math.ceil(num1)); //34
// -3 -2 -1 0 1 2 3
let str3 = "Hi";
let userName = "Hadi ";
let lastName = "Nsreeny ";
console.log(str3.trim());
console.log(str3.length);
// floor (0.444 * 2)
let randomNum = Math.floor(Math.random() * str3.length);
console.log(str3[randomNum]); //
// Js methods for str (.trim , .length , .includes , .split , .toUpperCase , .toLowerCase)
userName = "Hadi ";
lastName = "Nsreeny ";
// Nsreeny.toUpperCase()
let newLastName = lastName.trim().toUpperCase();
console.log(newLastName);
console.log(lastName);
console.log("Hi");
console.log(Math.floor(1.22) / Math.random());
let str4 = "Hi I like. I need a π£. I want to sleep. ";
console.log(str4.includes("ooooo"));
let strToArr = str4.split(".");
console.log(strToArr);
//console.log(userName.length);
// if
// || or, && and
if (1 == 122 || 1 == 1) {
console.log("hi");
x = 2 + 3;
console.log("π");
} else {
console.log("Not cool");
}
// if (con)
//{
// // correct
// } else {
// not true
//}
console.log("Hiiii");
// functions
function funName(num1, num2) {
// num1 = 3333; NEVER DO THAT IN YOUR LIFE π
console.log(num1);
let sumNumbers = 5555 + num1 * num2;
return sumNumbers;
}
// [ ] { } ( ) <> ; : , . - _ / \ ! ? @ % $
console.log(funName(44, 33));
// Es6 function
const functionName = () => {
return `I am Es6 function π`;
};
console.log(functionName());
// array
// 0 1 2
const names = ["Zain", "Olga", "Nancy"];
console.log(names[1]);
let number1 = 1;
//
console.log(names[number1]); // console.log(names[1])
number1++; // 2
console.log(names[number1]);
const NumArr = [22, 33, 55, 6754, 2, 22, 4, 55, 677, 432, 2];
console.log(NumArr[NumArr.length - 1]);
// for loop
let bOne = 33;
let billOneTip = 1.1;
result = `bOne ${Math.floor(bOne * billOneTip)} `;
console.log(result);