-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecond.html
More file actions
376 lines (269 loc) · 16.9 KB
/
second.html
File metadata and controls
376 lines (269 loc) · 16.9 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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta Tag -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ps0305</title>
<!-- Favicon -->
<link rel="shortcut icon" href="images/favicon/favicon.ico">
<link rel="apple-touch-icon" sizes="144x144" type="image/x-icon" href="images/favicon/apple-touch-icon.png">
<!-- All CSS Plugins -->
<link rel="stylesheet" type="text/css" href="css/plugin.css">
<!-- Main CSS Stylesheet -->
<link rel="stylesheet" type="text/css" href="css/style.css">
<!-- Google Web Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:400,300,500,600,700">
<!-- Syntax Highlighter -->
<link rel="stylesheet" type="text/css" href="css/syntax/shCore.css">
<link rel="stylesheet" type="text/css" href="css/syntax/shThemeDefault.css">
<!-- HTML5 shiv and Respond.js support IE8 or Older for HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Preloader Start -->
<div class="preloader">
<div class="rounder"></div>
</div>
<!-- Preloader End -->
<div id="main">
<div class="container">
<div class="row">
<!-- About Me (Left Sidebar) Start -->
<div class="col-md-3">
<div class="about-fixed">
<div class="my-pic">
<img src="images/pic/my-pic.png" alt="">
<a href="javascript:void(0)" class="collapsed" data-target="#menu" data-toggle="collapse"><i class="icon-menu menu"></i></a>
<div id="menu" class="collapse">
<ul class="menu-link">
<li><a href="about.html">About</a></li>
<li><a href="work.html">Work</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
</div>
<div class="my-detail">
<div class="white-spacing">
<h1>Pankaj Singh</h1>
<span>Self-taught Web Developer</span>
</div>
<ul class="social-icon">
<li>
<a href="https://github.com/ps0305" target="_blank" class="github">
<i class="fa fa-github"></i>
</a>
</li>
<li>
<a href="https://codepen.io/pankaj0305/" target="_blank" class="codepen">
<i class="fa fa-codepen"></i>
</a>
</li>
<li>
<a href="https://twitter.com/ps_0305" target="_blank" class="twitter">
<i class="fa fa-twitter"></i>
</a>
</li>
<li>
<a href="" target="_blank" class="linkedin">
<i class="fa fa-linkedin"></i>
</a>
</li>
</ul>
</div>
</div>
</div>
<!-- About Me (Left Sidebar) End -->
<!-- Blog Post (Right Sidebar) Start -->
<div class="col-md-9">
<div class="col-md-12 page-body">
<div class="row">
<div class="sub-title">
<a href="index.html" title="Go to Home Page"><h2>Back Home</h2></a>
<a href="#comment" class="smoth-scroll"><i class="icon-bubbles"></i></a>
</div>
<div class="col-md-12 content-page">
<div class="col-md-12 blog-post">
<!-- Post Headline Start -->
<div class="post-title">
<h1>JavaScript’s Filter Function Explained</h1>
</div>
<!-- Post Headline End -->
<!-- Post Detail Start -->
<div class="post-info">
<span>July 16, 2018 / by <a href="#" target="_blank">Pankaj Singh</a></span>
</div>
<!-- Post Detail End -->
<p>Compared to the map() and reduce() methods in JavaScript, the filter()method has probably the most straightforward name.</p>
<br>
<p>You input an array, and you filter out the elements that fulfill a specific condition into a new array.</p>
<p>This seems simple, but I always seemed to find myself reverting to for() loops. So, I decided to find a better way to understand how filter() functions worked.</p>
<br>
<p>I realized that filter functions are kind of like a college admissions officer. They use a set of parameters to decide which students should be admitted to their particular college. Yes, we all wish that colleges were a little more flexible and judged our accomplishments holistically, but in reality, most still have hard numbers around SAT, ACT and GPA scores that determine who will be considered.</p>
<p>Let’s get into it!</p>
<!-- Post Image Start -->
<div class="post-image">
<img src="images/blog/second1.png" alt="">
</div>
<!-- Post Image End -->
<br>
<h4>Using A For Loop Instead of Filter Function</h4>
<p>Okay, let’s say that we have an array of 4 students with names and GPAs. This particular college only wants to admit students with a 3.2 GPA or higher. Here is how you might do that.</p>
<script src="https://gist.github.com/ps0305/275f24b31b484a22dcf035047092e31d.js"></script>
<br>
<h4>Using the Filter() Method</h4>
<p>Let’s learn how to accomplish the same goal with the filter() method.</p>
<br>
<ol>
<li>Filter is an array method, so we will start with the array of students.</li>
<li>It uses a callback function that runs on each element in the array.</li>
<li>It uses a return statement to show which elements will actually end up in the final array, in this case, the admitted students.</li></ol>
<script src="https://gist.github.com/ps0305/4e995e8234d53946650e07f01a638287.js"></script>
<br>
<p>
The inputs and outputs are the same, so here’s what we did differently:</p>
<ol><li>We didn’t need to declare the admitted array and then fill it later. We declared it and then filled it with elements in the same code block</li>
<li>We actually used a condition within the return statement! That means that we only return elements that pass a certain condition.</li>
<li>We can now use student for each element in the array, rather than students[i] like we did in the for loop.</li>
</ol>
<!-- Post Image Start -->
<div class="post-image">
<img src="images/blog/second2.jpg" alt="">
</div>
<!-- Post Image End -->
<br>
<p>You may notice that one thing is counterintuitive- getting admitted to college is the last step, but in our code, the variable admitted is the first part of the statement! You might usually expect to find the final array as the last statement within the function. Instead, we use return to indicate which elements will end up in admitted.</p>
<br>
<!-- Post Image Start -->
<div class="post-image">
<img src="images/blog/second3.png" alt="">
</div>
<!-- Post Image End -->
<!-- Post Author Bio Box Start -->
<div class="about-author margin-top-70 margin-bottom-50">
<div class="picture">
<img src="images/blog/author.png" class="img-responsive" alt="">
</div>
<div class="c-padding">
<h3>Article By <a href="#" target="_blank" data-toggle="tooltip" data-placement="top" title="Visit Pankaj Website">Pankaj Singh</a></h3>
<p class="justify">Skilled in programming language JavaScript,
comfortable with the latest versions ES6. Also having good Python knowledge with strong OOPs concept.
Full Stack Developer using NodsJs/Django for Backend with CSS/HTML/JavaScript/MDBootstrap, API, MySQL,MongoDB,Github and Herokuapp.
Analytical thinker that consistently resolves ongoing issues or defects, often called upon
to consult on problem that have eluded resolution from others.</p>
</div>
</div>
<!-- Post Author Bio Box End -->
<!-- You May Also Like Start -->
<div class="you-may-also-like margin-top-50 margin-bottom-50">
<h3>You may also like</h3>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<a href="single.html"><p>Make mailchimp singup form working with ajax using jquery plugin</p></a>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<a href="single.html"><p>How to design elegant e-mail newsletter in html for wish christmas to your subscribers?</p></a>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<a href="single.html"><p>How to customize a wordpress theme entirely from scratch using a child theme?</p></a>
</div>
</div>
</div>
<!-- You May Also Like End -->
<!-- Post Comment (Disqus) Start -->
<div id="comment" class="comment">
<h3>Discuss about post</h3>
<!-- Disqus Code Start (Please Note: Disqus will not be load on local, You have to upload it on server.)-->
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = https://ps0305.github.io/{{ page.url }}";; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = "{{ page.id }}"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://ps0305-github-io.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<!-- Disqus Code End -->
</div>
<!-- Post Comment (Disqus) End -->
</div>
</div>
</div>
<!-- Subscribe Form Start -->
<div class="col-md-8 col-md-offset-2">
<form id="mc-form" method="post" action="#">
<div class="subscribe-form margin-top-20">
<input id="mc-email" type="email" placeholder="Email Address" class="text-input">
<button class="submit-btn" type="submit">Submit</button>
</div>
<p>Subscribe to my weekly newsletter</p>
<label for="mc-email" class="mc-label"></label>
</form>
</div>
<!-- Subscribe Form End -->
</div>
<!-- Footer Start -->
<div class="col-md-12 page-body margin-top-50 footer">
<footer>
<ul class="menu-link">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="work.html">Work</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
<p>© Copyright 2017 Pankaj Singh. All rights reserved</p>
</footer>
</div>
<!-- Footer End -->
</div>
<!-- Blog Post (Right Sidebar) End -->
</div>
</div>
</div>
<!-- Endpage Box (Popup When Scroll Down) Start -->
<div id="scroll-down-popup" class="endpage-box">
<h4>Read Also</h4>
<a href="#">How to make your company website based on bootstrap framework...</a>
</div>
<!-- Endpage Box (Popup When Scroll Down) End -->
<!-- Back to Top Start -->
<a href="#" class="scroll-to-top"><i class="fa fa-long-arrow-up"></i></a>
<!-- Back to Top End -->
<!-- All Javascript Plugins -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/plugin.js"></script>
<!-- Main Javascript File -->
<script type="text/javascript" src="js/scripts.js"></script>
<!-- Syntax Highlighter Javascript File -->
<script type="text/javascript" src="js/syntax/shCore.js"></script>
<script type="text/javascript" src="js/syntax/shBrushCss.js"></script>
<script type="text/javascript" src="js/syntax/shBrushJScript.js"></script>
<script type="text/javascript" src="js/syntax/shBrushPerl.js"></script>
<script type="text/javascript" src="js/syntax/shBrushPhp.js"></script>
<script type="text/javascript" src="js/syntax/shBrushPlain.js"></script>
<script type="text/javascript" src="js/syntax/shBrushPython.js"></script>
<script type="text/javascript" src="js/syntax/shBrushRuby.js"></script>
<script type="text/javascript" src="js/syntax/shBrushSql.js"></script>
<script type="text/javascript" src="js/syntax/shBrushVb.js"></script>
<script type="text/javascript" src="js/syntax/shBrushXml.js"></script>
<!-- Syntax Highlighter Call Function -->
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'js/syntax/clipboard.swf';
SyntaxHighlighter.all();
</script>
</body>
</html>