-
Notifications
You must be signed in to change notification settings - Fork 0
/
day1.js
180 lines (144 loc) · 2.9 KB
/
day1.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
const prompt = require('prompt-sync')();
// var number = prompt("enter your number:");
// console.log(number);
// DAY 1 . GOING TO LEARN SOME BASICS ABOUT THE JS
//EXE.2
console.log("heklo"); //just like print in python
let aa="karan singh";
console.log(aa);
//let var const difference
//EXE.3
console.log("difference between var , let, const");
const aurther="karan singh";
console.log(aurther);
var d=56;
let a=1;
let b=11;
let c=111;
console.log(a);
console.log(b);
console.log(c);
console.log(d);
//primitive data types
//EXE.4
//there are 7 primitive data types N-N-S-S-B-B-U-->NULL-NUMBER-SYMBOL-STRING-BOOLEAN-BIGINT-UNDEFINIED
//data types
//dynamic langauge
//1- permitive ,2-non-permitives
//permitives- 7 types
//1-string,2-number,3-boolean,4-null,5-undefined,6-symbol,7-bigint
//Non-permitives(refernce)
//array,object,functions
let x = null
let y= 345;
let z= true;
let w =BigInt("456");
let u="harry";
let v =Symbol("i m a symbol");
let k=undefined;
console.log(x,y,z,u,v,w,k);
console.log(typeof(k))
//objects just like dictionary in python (key value pairs)
const item={
"karan":"singh",
"rohit":true,
"kumar":67,
"tina":null
}
console.log(item["karan"])
item["rohit"]="hello"
console.log(item["rohit"])
console.log(item)
//operation & expression
//exe.6
//arithmetic
let g=10;
let f=90;
console.log(g+f);
console.log(g-f);
console.log(g*f);
console.log(g/f);
console.log(g**2);
// console.log(g//f);
console.log(g%f);
console.log(g++);
console.log(g);
console.log(g--);
console.log(g);
//assingment
let e=50;
e+=5;
console.log(e);// +=,-+,%=,*=,**= other opertor
//comparative
//==,>=,<=,!=,===,?,<,>,!==
o=90;
p=99
console.log(o==p)
console.log(o!=p)
console.log(o===p) //its also compare the data type of the variales
console.log(o!==p)
console.log(o>p)
console.log(o<p)
console.log(o>=p)
console.log(o<=p)
//logical
//&&,||,!
let num = 5
let num2= 55
console.log(num<=num2 && num!=num2);
console.log(!num)
//ternary opertaor
mark4=56
mark5=67
console.log(mark4>mark5 ? "yes":"no");
//conditional expressions
//exe.7
//if statement - if else , if..else if statements
let age=12;
if (age>18){
console.log("you are older than 18")
}
let age1=12;
if (age1>18){
console.log("you are older than 18")
}
else{
console.log("do not drive")
}
//let age3=
// age3=prompt("enter age :")
age3=45
age3=Number.parseInt(age3)
// if(age3>20){
// alert("yup");
// } alert giving error in terminal
let marks=410;
if (marks>450){
console.log("grade A");
}
else if (marks>400){
console.log("grade B");
}
else if (marks>350){
console.log("grade C");
}
else{
console.log("fail");
}
let marks9=2;
switch(marks9){
case 1:
console.log("one");
break;
case 2:
console.log("two");
break;
case 3:
console.log("three");
break;
case 4:
console.log("four");
break;
default:
console.log("not valid");
}