File tree Expand file tree Collapse file tree 5 files changed +151
-1
lines changed
css-questions/centering-a-div Expand file tree Collapse file tree 5 files changed +151
-1
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 " />
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6
+ < title > Centering a div</ title >
7
+ < link rel ="stylesheet " type ="text/css " href ="./style.css " />
8
+ </ head >
9
+ < body >
10
+ < div class ="parent ">
11
+ < div class ="child "> </ div >
12
+ </ div >
13
+ < script src ="./script.js "> </ script >
14
+ </ body >
15
+ </ html >
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Ways of centering a div
3
+ */
4
+
5
+ /*
6
+ * 1.
7
+ .parent {
8
+ height: 350px;
9
+ width: 350px;
10
+ background-color: blue;
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ }
15
+
16
+ .child {
17
+ height: 50%;
18
+ width: 50%;
19
+ background-color: red;
20
+ }
21
+ */
22
+
23
+ /*
24
+ * 2.
25
+ .parent {
26
+ height: 350px;
27
+ width: 350px;
28
+ background-color: blue;
29
+ display: grid;
30
+ place-items: center;
31
+ }
32
+
33
+ .child {
34
+ height: 50%;
35
+ width: 50%;
36
+ background-color: red;
37
+ }
38
+ */
39
+
40
+ .parent {
41
+ height : 350px ;
42
+ width : 350px ;
43
+ background-color : blue;
44
+
45
+ position : relative;
46
+ }
47
+
48
+ .child {
49
+ height : 50% ;
50
+ width : 50% ;
51
+ background-color : red;
52
+
53
+ position : absolute;
54
+ top : 50% ;
55
+ left : 50% ;
56
+ transform : translate (-50% , -50% );
57
+ }
Original file line number Diff line number Diff line change 9
9
10
10
< body >
11
11
Hello world
12
- < script src ="index.js "> </ script >
12
+ < button id ="my-btn "> Click me</ button >
13
+ < script src ="./namaste_js/15_event_loop.js "> </ script >
13
14
</ body >
14
15
</ html >
Original file line number Diff line number Diff line change
1
+ const input = {
2
+ name : 'Jay' ,
3
+ age : 25 ,
4
+ department : {
5
+ name : 'Customer Experience' ,
6
+ section : 'Technical' ,
7
+ branch : {
8
+ name : 'Bangalore' ,
9
+ timezone : 'IST' ,
10
+ } ,
11
+ } ,
12
+ company : {
13
+ name : 'SAP' ,
14
+ customers : [ 'Ford' , 'Nestle' ] ,
15
+ } ,
16
+ skills : [ 'javascript' , 'node.js' , 'html' ] ,
17
+ }
18
+
19
+ console . log ( input )
20
+
21
+ // Write a Function getValue that will take a dot string and an object and it will return its value in object
22
+
23
+ // If value doesn’t exist return undefined
24
+
25
+ let nestedObject = {
26
+ a : {
27
+ b : {
28
+ c : {
29
+ d : 'Hello D' ,
30
+ } ,
31
+ } ,
32
+ } ,
33
+ }
34
+ let nestedObject2 = {
35
+ a : {
36
+ b : {
37
+ c : {
38
+ d : 'Hello D' ,
39
+ } ,
40
+ } ,
41
+ } ,
42
+ }
43
+
44
+ // getValue(nestedObject, "a.b.c.d"); // OP: "Hello D"
45
+ // getValue(nestedObject2, "a.b.c.d.E"); // OP: undefined
46
+ // console.log(nestedObject.a.b.c.d)
47
+
48
+ const getValueMy = ( obj , dotString ) => {
49
+ const keys = dotString . split ( '.' )
50
+
51
+ let finalObj = obj
52
+
53
+ for ( const key of keys ) {
54
+ if ( typeof finalObj === 'object' && key in finalObj && finalObj != null ) {
55
+ finalObj = finalObj [ key ]
56
+ } else {
57
+ return undefined
58
+ }
59
+ }
60
+ return finalObj
61
+ }
62
+
63
+ const res = getValueMy ( nestedObject , 'a.b.c.d' ) // OP: "Hello D"
64
+
65
+ /*
66
+ *S Framework related (React JS & Vue JS) Qs:*
67
+
68
+ 1. useState, useEffect
69
+ - Is useState sync or async
70
+ - when does the useEffect runs
71
+ 2. Vue JS vs React JS
72
+ 3. Vue directives
73
+ 4. v-if vs v-show
74
+ 5. Watchers in Vue
75
+ 6. Lifecycle Hooks in Vue
76
+
77
+ */
You can’t perform that action at this time.
0 commit comments