<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Md.Saiful Islam on Medium]]></title>
        <description><![CDATA[Stories by Md.Saiful Islam on Medium]]></description>
        <link>https://medium.com/@saiful-islam-ice-45?source=rss-6fd0969b4496------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*psy8LZInFKwmCfPLBs8W9Q.jpeg</url>
            <title>Stories by Md.Saiful Islam on Medium</title>
            <link>https://medium.com/@saiful-islam-ice-45?source=rss-6fd0969b4496------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:47:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saiful-islam-ice-45/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[EC2 — The Cloud Server You Can Boss Around]]></title>
            <link>https://saiful-islam-ice-45.medium.com/ec2-the-cloud-server-you-can-boss-around-81235c8d1933?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/81235c8d1933</guid>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Thu, 15 May 2025 02:39:11 GMT</pubDate>
            <atom:updated>2025-05-15T02:39:11.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLGGion8Is2XxJpKtQyeFw.jpeg" /></figure><h4><strong>What the Heck is EC2?</strong></h4><p>EC2 stands for Elastic Compute Cloud. Fancy name, but here’s the real deal:</p><p><em>&gt; EC2 is just a virtual machine — a computer you rent by the hour (or second) in the AWS cloud.</em></p><p>It’s like renting a laptop from Amazon that you can power on, install stuff, run apps, host websites, shut it down, or even destroy — all from a browser or command line.</p><p>And since it’s elastic, you can scale up (add more power) or down (save money) any time.</p><p>Let’s say you’re building a portfolio website for your freelancing hustle. You need:</p><ul><li>A web server (Apache, Nginx)</li><li>A database</li><li>Full control of what’s running and how</li></ul><p>So instead of buying a physical laptop to host the site (which would be weird), you:</p><p>1. Spin up an EC2 instance<br>2. SSH into it<br>3. Deploy your code</p><p>Congrats! You&#39;re now a cloud developer.</p><h4><strong>Key Concepts to Know</strong></h4><p><strong>Term Meaning</strong></p><ol><li><strong>AMI(	Amazon Machine Image )—</strong> it’s like the OS blueprint (Ubuntu, Amazon Linux, etc.)</li><li><strong>Instance Type- </strong>Think like your laptop power<strong> </strong>laptop power level — t2.micro = basic, m5.large = beast</li><li><strong>Key Pair-</strong>	Your SSH login password alternative (private/public key)</li><li><strong>Security Group</strong>	<strong>(Firewall rules):</strong> what traffic is allowed in or out</li><li><strong>Elastic IP:</strong>	A static public IP address you can attach to your instance</li></ol><h4><strong>Let’s Build One (Hands-on Lab)</strong></h4><p>Step-by-step to launch EC2:</p><p>1. Go to AWS Console<br>2. Search for EC2<br>3. Click Launch Instance<br>4. Fill in:</p><ul><li><strong>Name</strong>: my-first-server</li><li><strong>AMI</strong>: Amazon Linux 2023</li><li><strong>Instance Type</strong>: t2.micro (free tier)</li><li><strong>Key Pair</strong>: Create one (download it!)</li><li><strong>Network Settings:</strong></li></ul><p>Allow SSH (port 22)</p><p>Allow HTTP (port 80) — for web servers</p><p>5. Click Launch Instance</p><p>Boom — your server is live!</p><p>6. SSH Into Your EC2 (Your Terminal is the Door)</p><pre># Go to where your key file is<br>cd ~/Downloads</pre><pre># Give proper permissions<br>chmod 400 my-key.pem</pre><pre># Connect to the server (replace with your EC2 public IP)<br>ssh -i &quot;my-key.pem&quot; ec2-user@your-ec2-public-ip</pre><p>Now you’re inside the server. Install stuff, deploy apps, whatever you like.</p><h4>Lets host a Web Page in 60 Seconds</h4><pre># Install web server<br>sudo yum install httpd -y</pre><pre># Start it<br>sudo systemctl start httpd</pre><pre># Enable on reboot<br>sudo systemctl enable httpd</pre><pre># Add a test page<br>echo &quot;Hello from EC2!&quot; | sudo tee /var/www/html/index.html</pre><p>Now go to your EC2 public IP in the browser. You should see your message. You just hosted a website.</p><h4>AWS CLI Love</h4><pre># List all instances<br>aws ec2 describe-instances</pre><pre># Stop an instance<br>aws ec2 stop-instances --instance-ids i-1234567890abcdef0</pre><pre># Start an instance<br>aws ec2 start-instances --instance-ids i-1234567890abcdef0</pre><p>That’s it — now you’ve got your own cloud server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81235c8d1933" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Design Patterns with Real Examples]]></title>
            <link>https://saiful-islam-ice-45.medium.com/react-design-patterns-with-real-examples-4a894596b444?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a894596b444</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react-design-pattern]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Sat, 10 May 2025 03:55:47 GMT</pubDate>
            <atom:updated>2025-05-10T03:55:47.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDwFklt2ax9x7otb1rY_lQ.png" /><figcaption>React Design Patterns</figcaption></figure><p>As a professional React developer, understanding and utilizing design patterns is essential for building scalable, maintainable, and efficient applications. Here, we will explore some of the most common React patterns and how they can enhance our development workflow.</p><h3>1. Presentational and Container Components</h3><p><strong>When to use:</strong> Separate logic from UI to make components clean and testable.</p><p><strong>Example:</strong></p><pre>// Container Component<br>function UserContainer() {<br>  const [user, setUser] = useState(null);<br>useEffect(() =&gt; {<br>    fetch(&#39;/api/user&#39;)<br>      .then(res =&gt; res.json())<br>      .then(setUser);<br>  }, []);<br>return &lt;UserProfile user={user} /&gt;;<br>}<br><br>// Presentational Component<br>function UserProfile({ user }) {<br>  if (!user) return &lt;p&gt;Loading...&lt;/p&gt;;<br>  return &lt;h1&gt;Welcome, {user.name}!&lt;/h1&gt;;<br>}</pre><h3>2. Compound Components</h3><p><strong>When to use:</strong> Build flexible, declarative APIs for UI components like tabs or accordions.</p><p><strong>Example: Tabs</strong></p><pre>const TabsContext = createContext();<br><br>function Tabs({ children, defaultIndex = 0 }) {<br>  const [activeIndex, setActiveIndex] = useState(defaultIndex);<br>  return (<br>    &lt;TabsContext.Provider value={{ activeIndex, setActiveIndex }}&gt;<br>      &lt;div className=&quot;tabs&quot;&gt;{children}&lt;/div&gt;<br>    &lt;/TabsContext.Provider&gt;<br>  );<br>}<br><br>function TabList({ children }) {<br>  return &lt;div className=&quot;tab-list&quot;&gt;{children}&lt;/div&gt;;<br>}<br><br>function Tab({ index, children }) {<br>  const { activeIndex, setActiveIndex } = useContext(TabsContext);<br>  return (<br>    &lt;button<br>      className={index === activeIndex ? &#39;active&#39; : &#39;&#39;}<br>      onClick={() =&gt; setActiveIndex(index)}<br>    &gt;<br>      {children}<br>    &lt;/button&gt;<br>  );<br>}<br><br>function TabPanels({ children }) {<br>  const { activeIndex } = useContext(TabsContext);<br>  return &lt;div&gt;{children[activeIndex]}&lt;/div&gt;;<br>}<br><br>function TabPanel({ children }) {<br>  return &lt;div&gt;{children}&lt;/div&gt;;<br>}<br><br>Tabs.List = TabList;<br>Tabs.Tab = Tab;<br>Tabs.Panels = TabPanels;<br>Tabs.Panel = TabPanel;</pre><p><strong>Usage:</strong></p><pre>&lt;Tabs&gt;<br>  &lt;Tabs.List&gt;<br>    &lt;Tabs.Tab index={0}&gt;Tab 1&lt;/Tabs.Tab&gt;<br>    &lt;Tabs.Tab index={1}&gt;Tab 2&lt;/Tabs.Tab&gt;<br>  &lt;/Tabs.List&gt;<br>  &lt;Tabs.Panels&gt;<br>    &lt;Tabs.Panel&gt;Content for Tab 1&lt;/Tabs.Panel&gt;<br>    &lt;Tabs.Panel&gt;Content for Tab 2&lt;/Tabs.Panel&gt;<br>  &lt;/Tabs.Panels&gt;<br>&lt;/Tabs&gt;</pre><h3>3. Render Props</h3><p><strong>When to use:</strong> Share code between components using a function as a child.</p><p><strong>Example:</strong></p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>// DataFetcher component that uses render props<br>const DataFetcher = ({ url, render }) =&gt; {<br>  const [data, setData] = useState(null);<br>  const [loading, setLoading] = useState(true);<br>  const [error, setError] = useState(null);<br><br>  useEffect(() =&gt; {<br>    const fetchData = async () =&gt; {<br>      try {<br>        const response = await fetch(url);<br>        if (!response.ok) {<br>          throw new Error(&#39;Network response was not ok&#39;);<br>        }<br>        const result = await response.json();<br>        setData(result);<br>      } catch (error) {<br>        setError(error);<br>      } finally {<br>        setLoading(false);<br>      }<br>    };<br><br>    fetchData();<br>  }, [url]);<br><br>  return render({ data, loading, error });<br>};<br><br>// Parent component that uses DataFetcher<br>const App = () =&gt; {<br>  return (<br>    &lt;DataFetcher <br>      url=&quot;https://api.example.com/data&quot; <br>      render={({ data, loading, error }) =&gt; {<br>        if (loading) return &lt;p&gt;Loading...&lt;/p&gt;;<br>        if (error) return &lt;p&gt;Error: {error.message}&lt;/p&gt;;<br>        return (<br>          &lt;div&gt;<br>            &lt;h1&gt;Fetched Data:&lt;/h1&gt;<br>            &lt;pre&gt;{JSON.stringify(data, null, 2)}&lt;/pre&gt;<br>          &lt;/div&gt;<br>        );<br>      }} <br>    /&gt;<br>  );<br>};<br><br>export default App;</pre><h3>4. Higher-Order Components (HOC)</h3><p><strong>When to use:</strong> Add behavior to components without modifying them.</p><p><strong>Example:</strong></p><pre>function withLogger(WrappedComponent) {<br>  return function(props) {<br>    console.log(&#39;Rendering&#39;, WrappedComponent.name);<br>    return &lt;WrappedComponent {...props} /&gt;;<br>  };<br>}<br><br>const Hello = () =&gt; &lt;h1&gt;Hello!&lt;/h1&gt;;<br>const HelloWithLogger = withLogger(Hello);</pre><h3>5. Custom Hooks</h3><p><strong>When to use:</strong> Extract logic from components to make them more reusable.</p><p><strong>Example:</strong></p><pre>function useFetch(url) {<br>  const [data, setData] = useState(null);<br><br>  useEffect(() =&gt; {<br>    fetch(url).then(res =&gt; res.json()).then(setData);<br>  }, [url]);<br>  return data;<br>}<br>// Usage<br>const posts = useFetch(&#39;/api/posts&#39;);</pre><h3>Conclusion</h3><p>Incorporating these patterns into our React development can significantly improve the structure and quality of our applications. As we grow more familiar with these patterns, we’ll find that they can simplify our code, enhance reusability, and ultimately lead to a better development experience.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a894596b444" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NLP Tutorial Part-1]]></title>
            <link>https://saiful-islam-ice-45.medium.com/nlp-tutorial-part-1-6d6288164fc2?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d6288164fc2</guid>
            <category><![CDATA[nltk]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ml-model]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Wed, 22 Mar 2023 06:40:17 GMT</pubDate>
            <atom:updated>2023-03-29T03:41:54.733Z</atom:updated>
            <content:encoded><![CDATA[<p>One day I was sitting and talking with my mom. Suddenly, pressing the home button of the mobile phone, a sentence came to me and my mother’s ears. Mom then said who was the girl? I didn’t know what to say then. Mom then got angry and asked me to tell her about that girl and her history. When I asked to google uncle without finding any way, he replied that this girl was actually Google Assistant.</p><p>When I asked him to tell me more about that girl, he told me to learn about NLP. Today I will share with you what I learned while learning NLP.</p><p><strong>NLP</strong> stands for Natural Language Processing, which is a field of computer science and artificial intelligence (AI) concerned with the interaction between computers and human (natural) languages. The goal of NLP is to enable machines to understand, interpret, and generate human language. That means that girl was actually a machine!! 😭</p><p>Let&#39;s see a mind map on NLP to get an overall idea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XsMt0XfkW0yYyj-w" /><figcaption>Mind Map on NLP</figcaption></figure><p>We use NLTK (Natural Language Toolkit) to learn NLP. According to the above mind map, first, we have to preprocess our collected data.</p><p><strong>Data Preprocessing</strong></p><p>This involves cleaning and formatting the raw text data, which may include tasks such as tokenization, stemming/lemmatization, and stop word removal etc. Let&#39;s see each part-</p><p><strong>Tokenization</strong></p><p>In simplest form, tokenization can be achieved by splitting text using whitespace. NLTK provides a function called <em>word_tokenize()</em> for splitting strings into tokens.</p><pre>import nltk<br>nltk.download(&quot;punkt&quot;)<br>from nltk.tokenize import word_tokenize<br>text= &quot;This is sample text for word tokenization&quot;<br>word_tokenize(text)<br><br>Output: [&quot;This&quot;, &quot;is&quot;, &quot;sample&quot;, &quot;text&quot;, &quot;for&quot;, &quot;word&quot;, &quot;tokenization&quot;]</pre><p><strong>Normalizing Case: </strong>It is common practice to convert all words to one case.</p><p><strong>Stemming and Lemmatization</strong></p><p>Stemming and lemmatization are used to reduce a word to its base form. For example <em>“Walk”</em> is the root for words like<em> “Walks”, “Walking”, “Walked”.</em></p><p>Most popular method is the <em>Porter-Stemming algorithm</em>. It&#39;s a Suffix stripping algorithm that does not rely on a lookup table that consists of inflected forms and root form relations. Some simple rules are built for extracting the root words.</p><pre>from nltk.stem import PorterStemmer<br>nltk.download(&#39;averaged_perceptron_tagger&#39;)<br>porter = PorterStemmer()<br><br>for word in [&#39;walking&#39;, &#39;walks&#39;, &#39;walked&#39;,&#39;ate&#39;, &#39;eats&#39; ]:<br>     print(porter.stem(word))<br><br>Output: [&#39;walk&#39;, &#39;walk&#39;, &#39;walk&#39;,&#39;ate&#39;,&#39;eats&#39;]</pre><p>sometimes meaning and context can be lost in the Stemming. lemmatization does very similar to stemming as it removes inflection and suffixes to convert words into their root words but also preserves the context.</p><pre>from nltk.stem import WordNetLemmatizer<br>nltk.download(&#39;averaged_perceptron_tagger&#39;)<br><br>wnl = WordNetLemmatizer()<br>nltk.download(&#39;wordnet&#39;)<br><br>for word in [&#39;walking&#39;, &#39;walks&#39;, &#39;walked&#39;]:<br>    print(wnl.lemmatize(word))</pre><p><strong>Stop Words</strong></p><p>Stop words are those words that do not contribute to the process of extracting/modeling the text data because they are the most common words such as: “<em>the</em>“, “<em>a</em>“, and “<em>is</em>“.</p><pre>nltk.download(&#39;stopwords&#39;)<br>from nltk.corpus import stopwords<br>stopwords_en = set(stopwords.words(&#39;english&#39;))<br>print(stopwords_en[:3])<br><br>Output: [&#39;i&#39;, &#39;me&#39;, &#39;my&#39;, &#39;myself&#39;]</pre><p>We can remove these from our input. We should also remove punctuation as it is also useless for our NLP model building. To have punctuation, we have default string library in python.</p><pre>from string import punctuation</pre><h4><strong>POS Tag</strong></h4><p>POS (Part of Speech) tagging is the process of labeling the words in a text corpus with their corresponding part of speech (noun, verb, adjective, etc.).</p><pre>import nltk<br>from nltk.tokenize import word_tokenize<br><br># Sample text<br>text = &quot;This is a sample sentence to demonstrate POS tagging in NLTK&quot;<br><br># Tokenize the text<br>tokens = word_tokenize(text)<br><br># Perform POS tagging<br>pos_tags = nltk.pos_tag(tokens)<br><br># Print the tagged tokens<br>print(pos_tags)<br><br>Output: [(&#39;This&#39;, &#39;DT&#39;), (&#39;is&#39;, &#39;VBZ&#39;), (&#39;a&#39;, &#39;DT&#39;), (&#39;sample&#39;, &#39;JJ&#39;), (&#39;sentence&#39;, &#39;NN&#39;), (&#39;to&#39;, &#39;TO&#39;), (&#39;demonstrate&#39;, &#39;VB&#39;), (&#39;POS&#39;, &#39;NNP&#39;), (&#39;tagging&#39;, &#39;VBG&#39;), (&#39;in&#39;, &#39;IN&#39;), (&#39;NLTK&#39;, &#39;NNP&#39;)]</pre><p><strong>Feature extraction methods</strong></p><p>Raw text cannot be directly fed into the machine learning algorithms. For that, we need to represent these documents in a way computers/algorithms understand i.e vectors of numbers. The way we achieve these are also called as feature extraction methods or feature encoding. Now, we will explore 3 very important feature extraction methods. Such as-</p><ul><li>(BOW)Bag of words</li><li>TF-IDF (Term Frequency- Inverse Document Frequency)</li><li>Word Embedding</li></ul><h4>1. Bag-of-Words</h4><p>This method is also referred to as count vectorization as it simply counts each individual word. To vectorize our documents, all we have to do is count how many times each word appears. Let&#39;s see how it works-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/0*IRO4uIZ2GCGgTvuJ.png" /><figcaption>Credit: Kowshik chilamkurthy</figcaption></figure><pre>from keras.preprocessing.text import Tokenizer<br>texts = [&quot;a dog live in home&quot;, &quot;a dog live in the hut&quot;, &quot; hut is dog home&quot;]<br>Tokenizer = Tokenizer()<br>Tokenizer.fit_on_texts(texts)<br>vectors = tokenizer.texts_to_matrix(texts, mode=&#39;count&#39;)<br>print(vectors)<br><br>Output: [[0. 1. 1. 1. 1. 1. 0. 0. 0.]<br>         [0. 1. 1. 1. 1. 0. 1. 1. 0.]<br>         [0. 1. 0. 0. 0. 1. 1. 0. 1.]]</pre><p><strong>2. TF-IDF (Term Frequency- Inverse Document Frequency)</strong><br><strong>TF-IDF </strong>is the combination of TF and IDF. We will try to understand both definitions in TF-IDF separately for better understanding.</p><p><strong>Term Frequency : tf(t,d)</strong></p><p>It uses to measure how frequently a word is presents in a document.<br>There are 2 popular methods to represent this.</p><ol><li><strong>Term frequency adjusted for document length:</strong><br> tf(t,d) = ( number of times term t appear in document d )÷ (number of words in d)</li><li><strong>logarithmically scaled frequency: </strong><br>tf(t,d) = log (1 + number of times term t appear in document d )</li></ol><p>Let&#39;s look at an example,</p><p>doc1 = ‘a dog live in home’</p><p><strong><em>1. tf(</em></strong>dog,doc1<strong><em>) = </em></strong><em>1/5.</em> (according to method 1)<br><strong><em>2. tf(</em></strong>dog,doc1<strong><em>) = 1+log(1)</em></strong>. (according to method 2)</p><p><strong>Inverse Document Frequency: idf</strong><br>IDF is a measure of term importance. It is a logarithmically scaled ratio of the total number of documents vs the count of documents with the term t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/0*vvE1MBdULsvwEGK3.png" /><figcaption>credit: Wiki</figcaption></figure><p>Example:<br>D =[ ‘a dog live in home’, ‘a dog live in the hut’, ‘hut is dog home’ ] <br>idf(dog, D) = log( total number of documents / total number of documents with term “dog”) = log(3/3) = log(1) = 0</p><h4>TFIDF: tf x idf</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/0*rdPikLO-bQYge8fy.png" /><figcaption>Credit: Wiki</figcaption></figure><p>Example:</p><pre>from sklearn.feature_extraction.text import TfidfVectorizer<br>texts = [&quot;a dog live in home&quot;, &quot;a dog live in the hut&quot;, &quot; hut is dog home&quot;]<br>vectorizer = TfidfVectorizer()<br>vectorizer.fit(texts)<br># get unique feature keys<br>vocabulary = vectorizer.get_feature_names()<br>print(vocabulary)<br># get unique feature matrix<br>document_vector = vectorizer.transform([texts[0]])<br>print(document_vector)<br><br>Output: [&#39;dog&#39;, &#39;home&#39;, &#39;hut&#39;, &#39;in&#39;, &#39;is&#39;, &#39;live&#39;]<br>  [[0.619130296489997<br>   0.7852882757103962,<br>   0.31412331085315044,<br>   0.31412331085315044]]</pre><p><strong>3. Word Embeddings</strong></p><p>With the help of deep learning, we use word embedding to vectorize our corpus (input document). These vectors work better for every NLP problem than sparse vectors like BOW and TF-IDF. Here, similar-meaning words have similar representations.<br>For example: “boat” and “ship” mean two different things in sparse vector representations, but not in embedding. There are two most popular and open-source embedding models are Word2Vec and GLoVe.</p><p><strong>Word2Vec</strong></p><p>If we want to know how Word2Vec works from inside, we have to know about the <strong>continuous bag-of-words (CBOW) model </strong>and the <strong>skip-gram model.</strong></p><ul><li><strong>CBOW</strong>: Word used in similar way/context results in similar representations. For example, synonyms like sad and unhappy are used in a similar context.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*-KCB84p2MIlwXC84.png" /><figcaption>Credit: Kowshik chilamkurthy</figcaption></figure><ul><li><strong>Skip-gram: </strong>CBOW model is trained to predict a target word based on the nearby context words, the skip-gram model is trained to predict the nearby context words based on the target word. It is exactly opposite to CBOW model.</li></ul><p>Now let’s see the code implementation-</p><pre>import nltk<br>nltk.download(&#39;punkt&#39;)<br>from gensim.models import Word2Vec<br>import numpy as np<br>import re<br><br>text = &quot;Word embedding made significant improvement in many NLP Task&quot;<br>text = re.sub(r&quot;[^A-Za-z]+&quot;, &#39; &#39;, text)  # Use a regex that removes non-alphabetic characters<br>sentences = nltk.sent_tokenize(text)<br>tokens = [nltk.word_tokenize(sentence) for sentence in sentences]<br>model = Word2Vec(tokens, size=50, sg=1, min_count=1)<br>model[&quot;the&quot;]</pre><p>It trains a Word2Vec model on the resulting list of tokenized sentences, with a vector size of 50, a CBOW algorithm (sg=1), and a minimum count of 1. Here sg=0 means Skip-gram algorithm`.</p><p>It’s not easy to understand girl’s mind ( Google Assistant) in a day. Long way to go, but not for today.</p><p><strong>References:</strong></p><ol><li>My younger brother ChatGPT</li><li><a href="https://medium.com/nerd-for-tech/nlp-zero-to-one-basics-part-1-30-35c3f6bc7097">https://medium.com/nerd-for-tech/nlp-zero-to-one-basics-part-1-30-35c3f6bc7097</a></li><li>Wikipedia for formula</li></ol><p>Thanks for your time. See you soon with rest of the part.</p><p>Bye Bye.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d6288164fc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Golang from ChatGPT]]></title>
            <link>https://saiful-islam-ice-45.medium.com/learn-golang-from-chatgpt-29c80c0b7dec?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/29c80c0b7dec</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[go-language]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Thu, 02 Feb 2023 10:50:07 GMT</pubDate>
            <atom:updated>2023-02-02T10:50:07.552Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4WFpegigJIvZH-hUhimSA.png" /></figure><p>Sound interesting?</p><p>Yeah!! Today we will learn how to learn something new with the help of chatGPT. In order to prepare for this, we will learn the Go language today.</p><p>Let&#39;s ask chatGPT what Golang is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H3O8RqRPxrfe1YXE6WtHeg.png" /></figure><p>amazing, huh? Now we know what Golang is.</p><p>Let&#39;s assume we have no prior knowledge of Golang. So, let&#39;s ask for a road map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b_U3EJg2JK_s2Kwpwkm0MQ.png" /><figcaption>ChatGPT Response</figcaption></figure><p>It provides us with a general summary, right? as a result, our sequential lifecycle might look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*hEKzxiFnvj0RJoYqyIIx5w.png" /><figcaption>Credit: Mindmup.com</figcaption></figure><p>Let&#39;s get acquainted with the syntax of Golang now. What will the answer be from ChatGPT?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*BvAy9scHcUKaI39mbuRkAQ.png" /><figcaption>Golang Syntax</figcaption></figure><p>wow!!! There might be no need for further explanation. So, there could be a few things we have like-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*qsTju0rjRkbfWcif07eVEQ.png" /></figure><p>Let&#39;s go through them one by one, beginning with variables.</p><p><strong>Variable:</strong></p><figure><img alt="Golang variable" src="https://cdn-images-1.medium.com/max/920/1*wcckypu2q4RLPQvXVqlIlQ.png" /><figcaption>Golang Variable</figcaption></figure><p>Is there any more to say about variables? Isn&#39;t the answer a resounding no?</p><p>Then proceed to ‘Types’.</p><figure><img alt="Golang types" src="https://cdn-images-1.medium.com/max/934/1*pH_YPhgF9Rsgp6r_wuQfag.png" /><figcaption>Golang Types</figcaption></figure><p>Golang also supports user define types like as —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*tyXBW5VOdHSyQGejQFRIEw.png" /></figure><p><strong>Control Structure?</strong></p><p>There are various types of control structures. Let&#39;s talk about them now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*1ry5_WrTYlw4PPPd_agsVw.png" /><figcaption>Golang control flow structure</figcaption></figure><p><strong>If-else statement:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*eAAJ0HY5YD-SIgt-BRNZxw.png" /></figure><p><strong>Switch Statement: </strong>switch statements used to select one of several code blocks to execute based on a value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*uMUNwDcAwn99UAh7zlKfvw.png" /></figure><p><strong>For Loop:</strong></p><p>For loop used to repeatedly execute a block of code. Go has several forms of the for loop, including:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*1TKETjJ7BjuNBiFMCbnzzw.png" /></figure><p>Now lets take a look in golang function.</p><h4><strong>Function</strong></h4><p>A function in Go is a reusable piece of code that takes parameters and returns a value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*Z37i8zPiUDGqjk83HSWszw.png" /><figcaption>Golang function</figcaption></figure><p>Let’s dive into golang pointer.</p><p><strong>Pointer:</strong></p><p>Pointer holds the memory address of a value.</p><p>Syntax:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*gkUMEUyhN2x-rvlbGSTelA.png" /><figcaption>Golang pointer syntax</figcaption></figure><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*RbG5lImngXzA6ejAvT1eYg.png" /><figcaption>Golang pointer example</figcaption></figure><p>The time has come to enter interface and leave function.</p><p><strong>Interface:</strong></p><p>An interface in Go is a type that defines a set of methods but leaves their implementation to concrete types.</p><p>Syntax:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*0za4tYXjqfi7bkrpO9nscg.png" /></figure><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*T7m63HDn55bhapH3wFcMZw.png" /></figure><p>In this example, an interface Shape is defined with one method Area that takes no parameters and returns a float64. A struct Rectangle is then defined with width and height fields of type float64. The Rectangle struct implements the Shape interface by defining a method named Area that calculates and returns the area of the rectangle. This means that any value of type Rectangle can be used wherever a value of type Shape is expected.</p><p>Now time to handle the error.</p><p><strong>Error Handling:</strong></p><p>Error handling in Go is typically done using the built-in error type, which is a simple interface type that represents an error condition. To return an error from a function, simply return a value of type error along with any other return values. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*pNLaBY0yL1RoFw2xZJP6UQ.png" /></figure><p>In this example, the divide function takes two int parameters, a and b, and returns an int result and an error value. If b is equal to 0, the function returns a result of 0 and an error value created using the fmt.Errorf function, which returns a new error with a formatted error message. If b is not equal to 0, the function returns the result of the division and a nil error value, which indicates that no error occurred.</p><p>To check the error value returned by a function, simply test it against nil:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*LIfnXk-wmBXkI_cuGSSFvA.png" /></figure><p>In this example, the divide function is called with the arguments 10 and 2. If an error occurs, the error message is printed, otherwise the result of the division is printed.</p><p>Huhhh. Continually interested in it? umm, You have enough patience, must say. I won’t have so. You can now inquire further with chatGTP.</p><p>Finally, Take a bite of the simple Golang program that concludes by expressing gratitude for your patience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*hqh4V870BVj2dFx257umbQ.png" /><figcaption>Golang program for gratitude</figcaption></figure><p>To run this program, save the code to a file with a .go extension (e.g. hello.go) and run the following command in the terminal and have my gratitude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*bFjE9j_xq7Cl-hvlfOMkGQ.png" /></figure><p>Bye Bye for Toady.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29c80c0b7dec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Does your code smell bad?]]></title>
            <link>https://saiful-islam-ice-45.medium.com/do-you-have-code-smell-in-your-code-d211e529de9b?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/d211e529de9b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[code-smells]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 04:50:24 GMT</pubDate>
            <atom:updated>2023-01-19T02:48:40.378Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*1sEW6FxFVLWfjpXZpQqTLA.png" /><figcaption>Code Smell</figcaption></figure><p><strong>Does your code smell bad?</strong></p><p>Before we get into the code smell, imagine the name of any of your coworkers you want to punch for bad code. I assume you have a lot in mind. If your colleague also has the same observation about you, what would be then? Therefore, if you want to be a good coworker, you should also be a good programmer.</p><p><strong>Code Smell !!!</strong></p><p>Code Smells are not the bugs of the program. Your program might function perfectly even when there are code smells. They do not prevent the program from functioning or are incorrect. They just signify the weakness in design and might increase the risk of bugs and program failure in the future.</p><p>Typical examples of code smells include the following:</p><ul><li>duplicate code</li><li>dead code</li><li>long methods</li><li>long parameter list</li><li>unnecessary comments</li><li>unnecessary primitive variables</li><li>data clumps etc.</li></ul><p>Now let&#39;s see how to eliminate this bad habit to be a good colleague.</p><p><strong>How to eliminate Code Smell?</strong></p><p>One of the best methods for getting rid of bad code smells and maintaining good code hygiene is code refactoring. Refactoring is a restructuring technique used to make the code clearer, shorter, and more effective without affecting its essential functionality.</p><p>Right now, What do you think? How to refactor and when?</p><p>It is best practice for programmers to clean up existing code before adding any new code. Secondly, after the team has deployed the code into production. Another good time to refactor code is after a team has deployed code into production.</p><p>Let&#39;s see few hacks to refactor existing code to make it code smell to good smell.</p><p><strong>Few Refactoring techniques</strong></p><ol><li>Code is broken down into smaller blocks of code. Fragmented code is then isolated, extracted and placed into a separate method. Then compose it a parent method.</li><li>Make a simplified method that is done with only one task.</li><li>Try to utilize Dependency Injection to reduce parameters of a method.</li><li>Remove dead code.</li><li>Follow the Law of Demeter. A method should know only its direct dependencies.</li><li>Be consistent. If you do something a certain way, do all similar things in the same way.</li></ol><p>Let&#39;s end with a quote-</p><p><em>“Any fool can write code that a computer can understand, good programmers write code that every human can understand. — Martin Fowler”</em></p><p><em>Thanks for your time.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d211e529de9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Different View of Fundamental JavaScript Algorithms.]]></title>
            <link>https://saiful-islam-ice-45.medium.com/different-view-of-fundamental-javascript-algorithms-5a6323eced25?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a6323eced25</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[js-algorithm]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[searching-algorithm]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 13:41:29 GMT</pubDate>
            <atom:updated>2021-04-11T18:25:25.175Z</atom:updated>
            <content:encoded><![CDATA[<h4>Describe both iterative and recursive way.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*8xoSS19ck0pZGk51Zhqa6A.jpeg" /><figcaption>Credit: Socket.io</figcaption></figure><p>Imagine it’s a beautiful morning, you are getting up from the bed and sitting on the sofa, clicking on the button of the TV in a relaxed mode to watch TV. Then, you realize you need to make your breakfast Afterall you are a bachelor by the way. There is a sequence of steps you need to follow to make your breakfast. This sequence of steps is called an <strong>algorithm</strong>. Clear!!!</p><p>Now take a long breath and try to introduce your breakfast ingredients.</p><h3>Linear search:</h3><p>It’s a searching algorithm that is used to find whether a number is present in an array or not. If it’s present, then at what location it occurs. It is also known as a sequential search. It is straightforward and works as follows: we compare each element with the target element to search until we find it or the list ends.</p><p>Linear search algorithm works in O(N) time complexity</p><p><strong>Recursive Method:</strong></p><pre>function linearSearch(arr,key) {</pre><pre>  function linearSearchRec(list, idx) {</pre><pre>     if (!list.length) return -1;</pre><pre>        const [head, …tail] = list;</pre><pre>     if (key === head) return idx;</pre><pre>      else return linearSearchRec(tail, idx + 1);</pre><pre>      }</pre><pre>   return linearSearchRec(arr, 0);</pre><pre>}</pre><pre>console.log(linearSearch([1,2,3,4,5,6], 5));</pre><p><strong>Iterative Method:</strong></p><pre>function linearSearch(arr,key)</pre><pre>{</pre><pre>for (let i = 0; i &lt; arr.length; i++)</pre><pre>if (arr[i] == x)</pre><pre>return i;</pre><pre>return “Not Found”;</pre><pre>}</pre><pre>console.log(linearSearch([5,11,7,8,9],21))</pre><pre>//output: Not Found</pre><h3>Binary Search:</h3><p>Binary Search is a searching technique that works depends on the Divide and Conquer approach. It used to search any element in a sorted array.</p><p><strong>Time Complexity: O(logN)</strong></p><p><strong>Recursive Method:</strong></p><pre>const binaryFunction =(arr, x, start, end) =&gt; {</pre><pre>if (start &gt; end) return “Not Found”;</pre><pre>let mid=Math.floor((start + end)/2);</pre><pre>if (arr[mid]===x) return mid;</pre><pre>if(arr[mid] &gt; x) return binaryFunction(arr, x, start, mid-1);</pre><pre>else return binaryFunction(arr, x, mid+1, end);</pre><pre>}</pre><pre>let arr = [1, 3, 5, 7, 8, 9];</pre><pre>let x = 5;</pre><pre>console.log(binaryFunction(arr, x, 0, arr.length-1));</pre><pre>//output: 2</pre><p><strong>Iterative Method:</strong></p><pre>const iterativeFunction =(arr, key) =&gt; {</pre><pre>let start=0, end=arr.length-1;</pre><pre>while (start&lt;=end){</pre><pre>let mid=Math.floor((start + end)/2);</pre><pre>if (arr[mid]===key) return mid;</pre><pre>else if (arr[mid] &lt; key)</pre><pre>start = mid + 1;</pre><pre>else</pre><pre>end = mid — 1;</pre><pre>}</pre><pre>return “Not Found”;</pre><pre>}</pre><pre>// Driver code</pre><pre>const arr = [1, 3, 5, 7, 8, 9];</pre><pre>const key = 5;</pre><pre>console.log(iterativeFunction(arr, key));</pre><h3>Fibonacci numbers:</h3><p>Fibonacci numbers are the numbers such that every number in the series after the first two is the sum of the two preceding ones. The series starts with 0, 1. Example −</p><pre>0,1, 1, 2, 3, 5, 8, 13, 21</pre><p><strong>Recursive Function:</strong></p><pre>const fib = number {</pre><pre>const result = [0, 1];</pre><pre>for (var i = 2; i &lt; n; i++) {</pre><pre>result.push(result[i-2] + result[i-1]);</pre><pre>}</pre><pre>return result;</pre><pre>}</pre><pre>console.log(fib(8));</pre><p><strong>Iterative method:</strong></p><pre>const fib= (n)=&gt;{</pre><pre>const fibArr = [0,1];</pre><pre>let prevs = 0;</pre><pre>let curr = 1;</pre><pre>let next;</pre><pre>if(n===1) return fibArr;</pre><pre>for(let i = 1;i&lt;n;i++){</pre><pre>next = prevs + curr;</pre><pre>fibArr.push(next);</pre><pre>prevs = curr;</pre><pre>curr = next;</pre><pre>}</pre><pre>return fibArr;</pre><pre>}</pre><pre>console.log(fib(8));</pre><pre>//output:[1,1,2,3,5,8,13,21]</pre><h3>Factorial:</h3><p>The factorial of a natural number is a number multiplied by “number minus one”, then by “number minus two”, and so on till 1. The factorial of n is denoted as n!</p><p>We can write a definition of factorial like this:</p><pre>n! = n * (n — 1) * (n — 2) * …*1</pre><p><strong>Recursive:</strong></p><pre>function rFact(num)</pre><pre>{</pre><pre>if (num === 0)</pre><pre>{ return 1; }</pre><pre>else</pre><pre>{ return num * rFact( num — 1 ); }</pre><pre>}</pre><pre>console.log(rFact(4));</pre><p><strong>Iterative:</strong></p><pre>function iFact(num)</pre><pre>{</pre><pre>var rval=1;</pre><pre>for (var i = 2; i &lt;= num; i++)</pre><pre>rval = rval * i;</pre><pre>return rval;</pre><pre>}</pre><pre>console.log(iFact(4));</pre><h3>Bubble Sort:</h3><p>Bubble Sort is a simple Sorting algorithm that works like as —</p><ul><li>Iterate through the array and check each element against the next element in the array.</li><li>If the current element is larger than the next element, swap them.</li><li>If it’s not greater, move the pointers up and compare the next two elements.</li><li>Once we reach the end of the array, we know that the largest element is in the last position.</li><li>Repeat this process N times where N is the length of the array, and each time, iterate up to the last-sorted element.</li></ul><p><strong>Implementation:</strong></p><pre>function bubbleSort(arr) {</pre><pre>for (let j = arr.length — 1; j &gt; 0; j — ) {</pre><pre>for (let i = 0; i &lt; j; i++) {</pre><pre>if (arr[i] &gt; arr[i + 1]) {</pre><pre>let temp = arr[i];</pre><pre>arr[i] = arr[i + 1];</pre><pre>arr[i + 1] = temp;</pre><pre>}</pre><pre>}</pre><pre>}</pre><pre>return arr;</pre><pre>}</pre><pre>console.log(bubbleSort([5,8,7,9,3,1]))</pre><h3>Insertion sort:</h3><p>Insertion sort will use the current item as a “key”, and then search through the items to the left of that item in the input list for the place that the key should go. This means that the sub-list to the left of the current “key” will already be sorted, and will remain sorted after every iteration of insertion sort</p><p><strong>Implementation:</strong></p><pre>let insertionSort = (inputArr) =&gt; {</pre><pre>for (let i = 1;length = inputArr.length,i &lt; length; i++) {</pre><pre>let key = inputArr[i];</pre><pre>let j = i — 1;</pre><pre>while (j &gt;= 0 &amp;&amp; inputArr[j] &gt; key) {</pre><pre>inputArr[j + 1] = inputArr[j];</pre><pre>j = j — 1;</pre><pre>}</pre><pre>inputArr[j + 1] = key;</pre><pre>}</pre><pre>return inputArr;</pre><pre>};</pre><pre>console.log(insertionSort([10,5,9,25,47,125]))</pre><h3>Selection Sort:</h3><p>Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[1]. Then find the second smallest element of A, and exchange it with A[2]. Continue in this manner for the first n-1 elements of A. This type of sorting is known as selection sort.</p><p><strong>Implementation:</strong></p><pre>function selectionSort(items){</pre><pre>let min;</pre><pre>for (i=0;len = items.length, i &lt; len; i++){</pre><pre>min = i;</pre><pre>for (j=i+1; j &lt; len; j++){</pre><pre>if (items[j] &lt; items[min]){</pre><pre>min = j;</pre><pre>}</pre><pre>}</pre><pre>if (i != min){</pre><pre>swap(items, i, min);</pre><pre>}</pre><pre>}</pre><pre>return items;</pre><pre>}</pre><pre>console.log(selectionSort([10,5,9,25,47,125]));</pre><p>Huh…Yeah!!! Finally, we have done for today. Bye for now. Happy Learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a6323eced25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mock Interview That Will Help You Get Hired …]]></title>
            <link>https://saiful-islam-ice-45.medium.com/mock-interview-that-will-help-you-get-hired-6f69ae4fb189?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f69ae4fb189</guid>
            <category><![CDATA[js-interview-questions]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[mock-interview]]></category>
            <category><![CDATA[frontend-development]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Sun, 17 May 2020 17:35:46 GMT</pubDate>
            <atom:updated>2020-05-17T17:35:46.021Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mock Interview That Will Help You Get Hired …</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lg7ui2SjMTaA7VE_.jpg" /><figcaption>Cadit<a href="https://alwaysask.net/interview-tips-that-will-help-you-get-hired-share-pin-share/">: Always ask</a></figcaption></figure><p>Today’s mock interview questions and answers are given below.</p><ol><li><strong>What is Inline Element</strong></li></ol><p><strong>Answer:</strong></p><p>Basically, an inline element does not cause a line break (start on a new line) and does not take up the full width of a page, only the space bounded by its opening and closing tag. It is usually used within other HTML elements.</p><p>Example of inline elements are:</p><p>· anchor &lt;a&gt; tag</p><p>· emphasis &lt;em&gt; tag</p><p>· image &lt;img&gt; tag</p><p><strong>2. What is block-level element?</strong></p><p><strong>Answer:</strong></p><p>A block-level element always starts on a new line and takes up the full width of a page, from left to right. A block-level element can take up one line or multiple lines and has a line break before and after the element.</p><p>Other examples of the block-level tag are:</p><ul><li>Heading tags &lt;h1&gt; to &lt;h6&gt;</li><li>List (Ordered, Unordered, Description and List Item) tags &lt;ol&gt; , &lt;ul&gt; ,&lt;dl&gt; , &lt;li&gt;</li><li>Pre-formatted text tag &lt;pre&gt;</li><li>Blockquote tag &lt;blockquote&gt;</li></ul><p>Example:</p><pre>&lt;div&gt;this is &lt;span&gt; inline element&lt;/span&gt;&lt;/div&gt;</pre><pre>&lt;div&gt;this is &lt;p&gt; block element&lt;/p&gt;&lt;/div&gt;</pre><p>Here first div show there result in a line but second div show there result in two line.</p><p><strong>3. HTML Attribute vs DOM property</strong></p><p><strong>Answer:</strong></p><p>When writing HTML source code,it can define <em>attributes</em> on HTML elements. Then, once the browser parses the code, a corresponding DOM node will be created. This node is an object, and therefore it has <em>properties</em>.</p><p>That means <strong>Attributes are defined by HTML. Properties are defined by the DOM.Attributes <em>initialize</em> DOM properties and then they are done. One more thing is — Property values can change; attribute values can’t.</strong></p><p>For instance, this HTML element:</p><p>&lt;input type=”text” value=”Name:”&gt;</p><p>has 2 attributes (type and value).</p><p><strong>4. Instance Member vs prototype member.</strong></p><p><strong>Answer:</strong></p><p>A prototype property will be part of any object created from the so-called prototype, and this includes prototype chain.</p><p>A instance property will be part of the whole instance.</p><p>Let’s see an example to clarify this two things.</p><pre>function Person(first, last, age) {</pre><pre>this.firstName = first;</pre><pre>this.lastName = last;</pre><pre>this.age = age;</pre><pre>}</pre><pre>Person.prototype.planet = &quot;Earth&quot;;</pre><pre>p1 = new Person(&quot;David&quot;, &quot;Beckham&quot;, 39);</pre><pre>p2 = new Person(&quot;Lionel&quot;, &quot;Messi&quot;, 30);</pre><pre>console.log(p1.planet) // Earth</pre><pre>Person.prototype.planet = &quot;Mars&quot;</pre><pre>console.log(p1.planet) // Mars</pre><pre>console.log(p1.planet === p2.planet) // true</pre><p><strong>5. Hoisting:</strong></p><p>In JavaScript, Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution. Basically, it gives us an advantage that no matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local.</p><p>Example:</p><pre>// hoisting</pre><pre>function codeHoist(){</pre><pre>a = 10;</pre><pre>let b = 50;</pre><pre>}</pre><pre>codeHoist();</pre><pre>console.log(a); // 10</pre><pre>console.log(b); // ReferenceError : b is not defined</pre><p>Here a act as a global variable and hoisted to the top of the code and can be access from outside the function but b is local variable that’s why we are not access it from outside of the function.</p><p><strong>6.Difference </strong><strong>Typeof and </strong><strong>Instance of?</strong></p><p><strong>Answer:</strong></p><p>typeof is a <em>unary operator</em> that returns a string indicating the type of the unevaluated operand.</p><p>instanceof is a binary operator, accepting an object and a constructor. It returns a boolean indicating whether or not the object has the given constructor in its prototype chain.</p><p>Example:</p><pre>const isString = (str) =&gt; {</pre><pre>return typeof str === &#39;string&#39; || str instanceof String</pre><pre>}</pre><p><strong>7. What is Babel?</strong></p><p><strong>Answer:</strong></p><p>Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. Here are the main things Babel can do for you:</p><p>· Transform syntax</p><p>· Polyfill features that are missing in your target environment</p><p>· Source code transformations</p><p>Example:</p><pre>// Babel Input: ES2015 arrow function</pre><pre>[1, 2, 3].map((n) =&gt; n + 1);</pre><pre>// Babel Output: ES5 equivalent</pre><pre>[1, 2, 3].map(function(n) {</pre><pre>return n + 1;</pre><pre>});</pre><p><strong>8. Advantages of MongoDB.</strong></p><p><strong>Answer:</strong></p><p>The following are the few advantages of MongoDB NoSQL database over relational databases.</p><p>· MongoDB is a schema-less NoSQL database. We do not need to design the schema of the database when we are using MongoDB</p><p>· No complex joins are needed in MongoDB. There is no relationship among data in MongoDB</p><p>· MongoDB is easy to scale.</p><p>· It is very easy to set-up and install MongoDB.</p><p>· The document query language supported by MongoDB is very simple as compared to SQL queries.</p><p>· Because the MongoDB uses JSON format to store data, it is very easy to store arrays and objects.</p><p>· MongoDB is free to use. There is no cost for it. etc.</p><p><strong>9. What is async/await?</strong></p><p><strong>Answer:</strong></p><p>async/await is the new way of writing asynchronous or non-blocking code in JavaScript’s. It is built on top of Promises. It makes writing asynchronous code more readable and cleaner than Promises and Callbacks.</p><p><strong>10. What does data structure mean? Say somethings on Stack and Queue data structure.</strong></p><p><strong>Answer:</strong></p><p>A data structure is a specialized format for organizing, processing, retrieving and storing data. While there <strong>are</strong> several basic and advanced structure types, any data structure is designed to arrange data to suit a specific purpose so that it <strong>can</strong> be accessed and worked with in appropriate ways.</p><p><strong>Stack:</strong></p><p>. Stack follow a basic principle that is called LIPO (Last In First Out).That means we must delete the last element that pushed in stack. Let’s try to understand with the help of a real life example. When we browse a website, we may click link to go to another page. In that time web browser push an element in stack and if we click at back button, it removes last value and back us to previous page. It has three operational methods:</p><p>i) Push() — Add a value in stack</p><p>ii) Pop() — delete a value from stack</p><p>iii) Peek — Peek a value from stack</p><p><strong>Queue:</strong></p><p>It looks similar with stack but its follow FIFO (First In First Out) principle.</p><p>It also have three methods like as stack such as-</p><p>i) Enqueue() — Add a value in queue</p><p>ii) Dequeue() — delete a value from queue</p><p>iii) Peek — Peek a value from stack.</p><p>That’s all.Thank you😊.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f69ae4fb189" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mock Interview Test.]]></title>
            <link>https://saiful-islam-ice-45.medium.com/mock-interview-test-93f8aaf936c0?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/93f8aaf936c0</guid>
            <category><![CDATA[web-developement]]></category>
            <category><![CDATA[mock-interview]]></category>
            <category><![CDATA[js-interview-questions]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Sun, 17 May 2020 17:31:43 GMT</pubDate>
            <atom:updated>2020-05-17T17:31:43.175Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lg7ui2SjMTaA7VE_.jpg" /><figcaption>Cadit<a href="https://alwaysask.net/interview-tips-that-will-help-you-get-hired-share-pin-share/">: Always ask</a></figcaption></figure><p>Today’s mock interview questions and answers are given below.</p><ol><li><strong>What is Inline Element</strong></li></ol><p><strong>Answer:</strong></p><p>Basically, an inline element does not cause a line break (start on a new line) and does not take up the full width of a page, only the space bounded by its opening and closing tag. It is usually used within other HTML elements.</p><p>Example of inline elements are:</p><p>· anchor &lt;a&gt; tag</p><p>· emphasis &lt;em&gt; tag</p><p>· image &lt;img&gt; tag</p><p><strong>2. What is block-level element?</strong></p><p><strong>Answer:</strong></p><p>A block-level element always starts on a new line and takes up the full width of a page, from left to right. A block-level element can take up one line or multiple lines and has a line break before and after the element.</p><p>Other examples of the block-level tag are:</p><ul><li>Heading tags &lt;h1&gt; to &lt;h6&gt;</li><li>List (Ordered, Unordered, Description and List Item) tags &lt;ol&gt; , &lt;ul&gt; ,&lt;dl&gt; , &lt;li&gt;</li><li>Pre-formatted text tag &lt;pre&gt;</li><li>Blockquote tag &lt;blockquote&gt;</li></ul><p>Example:</p><pre>&lt;div&gt;this is &lt;span&gt; inline element&lt;/span&gt;&lt;/div&gt;</pre><pre>&lt;div&gt;this is &lt;p&gt; block element&lt;/p&gt;&lt;/div&gt;</pre><p>Here first div show there result in a line but second div show there result in two line.</p><p><strong>3. HTML Attribute vs DOM property</strong></p><p><strong>Answer:</strong></p><p>When writing HTML source code,it can define <em>attributes</em> on HTML elements. Then, once the browser parses the code, a corresponding DOM node will be created. This node is an object, and therefore it has <em>properties</em>.</p><p>That means <strong>Attributes are defined by HTML. Properties are defined by the DOM.Attributes <em>initialize</em> DOM properties and then they are done. One more thing is — Property values can change; attribute values can’t.</strong></p><p>For instance, this HTML element:</p><p>&lt;input type=”text” value=”Name:”&gt;</p><p>has 2 attributes (type and value).</p><p><strong>4. Instance Member vs prototype member.</strong></p><p><strong>Answer:</strong></p><p>A prototype property will be part of any object created from the so-called prototype, and this includes prototype chain.</p><p>A instance property will be part of the whole instance.</p><p>Let’s see an example to clarify this two things.</p><pre>function Person(first, last, age) {</pre><pre>    this.firstName = first;</pre><pre>    this.lastName = last;</pre><pre>    this.age = age;</pre><pre>}</pre><pre>Person.prototype.planet = &quot;Earth&quot;;</pre><pre>p1 = new Person(&quot;David&quot;, &quot;Beckham&quot;, 39);</pre><pre>p2 = new Person(&quot;Lionel&quot;, &quot;Messi&quot;, 30);</pre><pre>console.log(p1.planet) // Earth</pre><pre>Person.prototype.planet = &quot;Mars&quot;</pre><pre>console.log(p1.planet) // Mars</pre><pre>console.log(p1.planet === p2.planet) // true</pre><p><strong>5. Hoisting:</strong></p><p>In JavaScript, Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution. Basically, it gives us an advantage that no matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local.</p><p>Example:</p><pre>// hoisting</pre><pre>function codeHoist(){</pre><pre>   a = 10;</pre><pre>   let b = 50;</pre><pre>}</pre><pre>codeHoist();</pre><pre>console.log(a); // 10</pre><pre>console.log(b); // ReferenceError : b is not defined</pre><p>Here a act as a global variable and hoisted to the top of the code and can be access from outside the function but b is local variable that’s why we are not access it from outside of the function.</p><p><strong>6.Difference </strong><strong>Typeof and </strong><strong>Instance of?</strong></p><p><strong>Answer:</strong></p><p>typeof is a <em>unary operator</em> that returns a string indicating the type of the unevaluated operand.</p><p>instanceof is a binary operator, accepting an object and a constructor. It returns a boolean indicating whether or not the object has the given constructor in its prototype chain.</p><p>Example:</p><pre>const isString = (str) =&gt; {</pre><pre>return typeof str === &#39;string&#39; || str instanceof String</pre><pre>}</pre><p><strong>7. What is Babel?</strong></p><p><strong>Answer:</strong></p><p>Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. Here are the main things Babel can do for you:</p><p>· Transform syntax</p><p>· Polyfill features that are missing in your target environment</p><p>· Source code transformations</p><p>Example:</p><pre>// Babel Input: ES2015 arrow function</pre><pre>[1, 2, 3].map((n) =&gt; n + 1);</pre><pre>// Babel Output: ES5 equivalent</pre><pre>[1, 2, 3].map(function(n) {</pre><pre>    return n + 1;</pre><pre>});</pre><p><strong>8. Advantages of MongoDB.</strong></p><p><strong>Answer:</strong></p><p>The following are the few advantages of MongoDB NoSQL database over relational databases.</p><p>· MongoDB is a schema-less NoSQL database. We do not need to design the schema of the database when we are using MongoDB</p><p>· No complex joins are needed in MongoDB. There is no relationship among data in MongoDB</p><p>· MongoDB is easy to scale.</p><p>· It is very easy to set-up and install MongoDB.</p><p>· The document query language supported by MongoDB is very simple as compared to SQL queries.</p><p>· Because the MongoDB uses JSON format to store data, it is very easy to store arrays and objects.</p><p>· MongoDB is free to use. There is no cost for it. etc.</p><p><strong>9. What is async/await?</strong></p><p><strong>Answer:</strong></p><p>async/await is the new way of writing asynchronous or non-blocking code in JavaScript’s. It is built on top of Promises. It makes writing asynchronous code more readable and cleaner than Promises and Callbacks.</p><p><strong>10. What does data structure mean? Say somethings on Stack and Queue data structure.</strong></p><p><strong>Answer:</strong></p><p>A data structure is a specialized format for organizing, processing, retrieving and storing data. While there <strong>are</strong> several basic and advanced structure types, any data structure is designed to arrange data to suit a specific purpose so that it <strong>can</strong> be accessed and worked with in appropriate ways.</p><p><strong>Stack:</strong></p><p>. Stack follow a basic principle that is called LIPO (Last In First Out).That means we must delete the last element that pushed in stack. Let’s try to understand with the help of a real life example. When we browse a website, we may click link to go to another page. In that time web browser push an element in stack and if we click at back button, it removes last value and back us to previous page. It has three operational methods:</p><p>i) Push() — Add a value in stack</p><p>ii) Pop() — delete a value from stack</p><p>iii) Peek — Peek a value from stack</p><p><strong>Queue:</strong></p><p>It looks similar with stack but its follow FIFO (First In First Out) principle.</p><p>It also have three methods like as stack such as-</p><p>i) Enqueue() — Add a value in queue</p><p>ii) Dequeue() — delete a value from queue</p><p>iii) Peek — Peek a value from stack.</p><p>That’s all.Thank you😊.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93f8aaf936c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Fundamental Problem Solving Elements.]]></title>
            <link>https://saiful-islam-ice-45.medium.com/10-fundamental-problem-solving-elements-a933f84b1d4d?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/a933f84b1d4d</guid>
            <category><![CDATA[competitive-programming]]></category>
            <category><![CDATA[js-interview-questions]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[problem-solving]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Sat, 16 May 2020 17:38:14 GMT</pubDate>
            <atom:updated>2020-05-16T17:38:14.301Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*VPuE94vuzC6uv9HN.jpg" /><figcaption>Credit<a href="https://jacobward.io/post/solving-javascript-interview-question/">:Jacob Ward</a></figcaption></figure><p>Today We will see 10 frequently used problem solving paradigm.Let’s get started —</p><p><strong>1)</strong> <strong>Given a string, reverse each word in the sentence.</strong></p><p>Sample input:</p><p>Welcome to this Javascript Guide!</p><p>Sample Output:</p><p>emocleW ot siht tpircsavaJ !ediuG</p><p><strong>Solution:</strong></p><pre>var string = “Welcome to this Javascript Guide!”;</pre><pre>var reverseEntireSentence = reverseBySeparator(string, “”);</pre><pre>var reverseEachWord = reverseBySeparator(reverseEntireSentence, “ “);</pre><pre>function reverseBySeparator(string, separator) {</pre><pre>return string.split(separator).reverse().join(separator);</pre><pre>}</pre><p>When we split without any space it separates character by character and reverse function also reverse character by character and join function join separated character into a string.</p><p>But when we split with a space it separates word by word and reverse function also reverse word by word and join function join separated word into a string.</p><p><strong>2)</strong> <strong>Write a “mul” function which will properly when invoked as below syntax.</strong></p><pre>console.log(mul(2)(3)(4)); // output : 24</pre><pre>console.log(mul(4)(3)(4)); // output : 48</pre><p>We can solve this problem by using closure. Closure is a function that takes another function as a parameter or return another function.</p><p><strong>Solution:</strong></p><pre>function mul (x) {</pre><pre>return function (y) {</pre><pre>return function (z) {</pre><pre>return x * y * z;</pre><pre>};</pre><pre>};</pre><pre>}</pre><p>Here mul function accept the first argument and return anonymous function which take the second parameter and return anonymous function which take the third parameter and return multiplication of arguments which is being passed in successive.</p><p><strong>3) How to empty an array in JavaScript?</strong></p><p>We can do it many way —</p><p><strong>Method-1:</strong></p><pre>arrayList = [];</pre><p>Above code will set the variable arrayList to a new empty array.</p><p><strong>Method 2</strong></p><pre>arrayList.length = 0;</pre><p>Above code will clear the existing array by setting its length to 0.</p><p><strong>Method 3</strong></p><pre>arrayList.splice(0, arrayList.length);</pre><p>Splice function updates not only the length of the array but also reference of the array too.</p><p>For instance,</p><pre>var arrayList = [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;, &#39;f&#39;]; // Created array</pre><pre>var anotherArrayList = arrayList;  // Referenced arrayList by another variable</pre><pre>arrayList.splice(0, arrayList.length); // Empty the array by setting length to 0</pre><pre>console.log(anotherArrayList);</pre><p><strong>Method 4</strong></p><pre>while(arrayList.length) {</pre><pre>arrayList.pop();</pre><pre>}</pre><p>Above implementation can also empty the array</p><p><strong>4) How to check if an object is an array or not?</strong></p><p>In modern browser, we can use isArray property of Array object.</p><pre>Array.isArray(arrayList);</pre><p>If we want we can use JQuery like as —</p><pre>if($.isArray(arrayList)) {</pre><pre>console.log(&#39;Array&#39;);</pre><pre>} else {</pre><pre>console.log(&#39;Not an array&#39;);</pre><pre>}</pre><p><strong>5) How would you use a closure to create a private counter?</strong></p><p><strong>Answer:</strong><br> You can create a function within an outer function (a closure) that allows you to update a private variable but the variable wouldn’t be accessible from outside the function without the use of a helper function.</p><pre>function counter() {</pre><pre>var _counter = 0;</pre><pre>add: function(increment) { _counter += increment; },</pre><pre>retrieve: function() { return ‘The counter is currently at: ‘ + _counter; }</pre><pre>}</pre><pre>}</pre><pre>var c = counter();</pre><pre>c.add(5);</pre><pre>c.add(9);</pre><pre>c.retrieve();</pre><p>Here return an object with several functions that allow us to modify the private _counter variable. It shows error if we try to access the private variable like below _counter. That’s Why we use our counter function.</p><p><strong>6) How would you check if a number is an integer?</strong></p><p><strong>Answer:</strong><br> A very simply way to check if a number is a decimal or integer is to see if there is a remainder left when you divide by 1.</p><pre>function isInt(num) {</pre><pre>return num % 1 === 0;</pre><pre>}</pre><pre>console.log(isInt(4)); // true</pre><pre>console.log(isInt(12.2)); // false</pre><pre>console.log(isInt(0.3)); // false</pre><p>We can also do it like as below –</p><pre>function isInt(num) {</pre><pre>return num == parseInt(num);</pre><pre>}</pre><pre>console.log(isInt(4)); // true</pre><pre>console.log(isInt(12.2)); // false</pre><pre>console.log(isInt(0.3)); // false</pre><p><strong>7) FizzBuzz Challenge</strong></p><p>Create a for loop that iterates up to 100 while outputting &quot;fizz&quot; at multiples of 3, &quot;buzz&quot; at multiples of 5 and &quot;fizzbuzz&quot; at multiples of 3 and 5.</p><p><strong>Answer:</strong></p><pre>for (let i = 1; i &lt;= 100; i++) {</pre><pre>let f = i % 3 == 0,</pre><pre>b = i % 5 == 0;</pre><pre>console.log(f ? (b ? &#39;FizzBuzz&#39; : &#39;Fizz&#39;) : b ? &#39;Buzz&#39; : i);</pre><pre>}</pre><p>Here first we check whether i is divided by 3 or 5, if f is true then check, is b also true or not, if b also that means i is divided by 3 as well as 5 and return ‘FizzBuzz’ but if b is false that means also f true and return ‘Fizz’ but if only b is true then return ‘Buzz’ otherwise return i only.</p><p><strong>8) Given two strings, return true if they are anagrams of one another.</strong></p><p><strong>Answer:</strong></p><p>Anagram is a word, phrase, or name formed by rearranging the letters of another.</p><p>Such as spar, formed from rasp.</p><pre>var firstWord = &quot;Mary&quot;;</pre><pre>var secondWord = &quot;Army&quot;;</pre><pre>isAnagram(firstWord, secondWord); // true</pre><pre>function isAnagram(first, second) {</pre><pre>// For case insensitivity</pre><pre>var a = first.toLowerCase();</pre><pre>var b = second.toLowerCase();</pre><pre>a = a.split(&quot;&quot;).sort().join(&quot;&quot;);</pre><pre>b = b.split(&quot;&quot;).sort().join(&quot;&quot;);</pre><pre>return a === b;</pre><pre>}</pre><p>Here first split the strings then sort the strings, and join the resulting array to a string. Finally compare the results.</p><p><strong>9) What will be the output of the following code?</strong></p><pre>var y = 1;</pre><pre>if (function f() {}) {</pre><pre>y += typeof f;</pre><pre>}</pre><pre>console.log(y);</pre><p><strong>Answer:</strong><br> Above code would give output 1undefined. If condition statement evaluate using eval so eval(function f() {}) which return function f() {} which is true so inside if statement code execute. typeof f return undefined because if statement code execute at run time, so statement inside if condition evaluated at run time.</p><p>Rather we can do as —</p><pre>var k = 1;</pre><pre>if (1) {</pre><pre>function foo() {};</pre><pre>k += typeof foo;</pre><pre>}</pre><pre>console.log(k); // output 1function</pre><p><strong>10) When would you use the “bind” function?</strong></p><p><strong>Answer:</strong><br> A good use of the bind function is when you have a particular function that you want to call with a specific this value. You can then use bind to pass a specific object to a function that uses a this reference.</p><pre>function fullName() {</pre><pre>return &quot;Hello, this is &quot; + this.first + &quot; &quot; + this.last;</pre><pre>}</pre><pre>console.log(fullName()); // =&gt; Hello this is undefined undefined</pre><pre>// create a person object and pass its values to the fullName function</pre><pre>var person = {first: &quot;Foo&quot;, last: &quot;Bar&quot;};</pre><pre>console.log(fullName.bind(person)()); // =&gt; Hello this is Foo Bar</pre><p>If we understand above this 10 problem. We can easily solve many problem using these concept. Hopefully we understood everything.</p><p>No more today. Thanks you😊.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a933f84b1d4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Things That I have learned During Problem Solve.]]></title>
            <link>https://saiful-islam-ice-45.medium.com/10-things-that-i-have-learned-during-problem-solve-35f0688c5bee?source=rss-6fd0969b4496------2</link>
            <guid isPermaLink="false">https://medium.com/p/35f0688c5bee</guid>
            <category><![CDATA[problem-solving]]></category>
            <dc:creator><![CDATA[Md.Saiful Islam]]></dc:creator>
            <pubDate>Fri, 15 May 2020 17:50:37 GMT</pubDate>
            <atom:updated>2020-05-15T17:52:47.426Z</atom:updated>
            <content:encoded><![CDATA[<h3>10 Things That I have learned During Problem Solving.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q92LA5SJcvgs9UqQ.jpg" /></figure><p>Today I learned this 10 things.</p><p><strong>1) parseInt():</strong></p><p>The parseInt() function parses a string and returns an integer.</p><pre>const parsed = parseInt(x, base);</pre><p><strong>2) parseFloat()</strong></p><p>The <strong>parseFloat()</strong> function parses an argument and returns a floating point number.</p><p><strong>3) Factorial:</strong></p><p>The factorial function says to multiply all whole numbers from our chosen number down to 1.</p><p>Examples:</p><pre>4! = 4 × 3 × 2 × 1 = 24</pre><pre>7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040</pre><pre>1! = 1</pre><p><strong>4) Recursive Method:</strong></p><p>Recursive function is a function that call itself until it reaches a threshold value.</p><pre>function factorial(n) {</pre><pre>if(n===0) return 1;</pre><pre>return n*factorial(n-1);</pre><pre>}</pre><p><strong>5) Math.PI :</strong></p><p>The <strong>Math</strong>. <strong>PI</strong> is a property in <strong>JavaScript</strong> which is simply used to find the value of <strong>Pi</strong> i.e, in symbolic form Π which is nothing but it is the ratio of the circumference of a circle to its diameter, whose value is approximately 3.141</p><p><strong>6) Multiple Switch:</strong></p><p>We can define a singe scope for multiple cases if needed.</p><p>Example:</p><pre>switch(condition) {<br> case “a”:<br> case “e”:<br> case “i”:<br> case “o”:<br> case “u”:<br> return “A”; <br> break;</pre><p><strong>7) Regular expressions:</strong></p><p>Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects.</p><p>Example:</p><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_dot.asp">.</a> =&gt; Find a single character, except newline or line terminator</pre><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_wordchar.asp">\w</a> =&gt; Find a word character</pre><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_wordchar_non.asp">\W</a> =&gt;Find a non-word character</pre><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_digit.asp">\d</a> =&gt;Find a digit</pre><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_digit_non.asp">\D</a> =&gt; Find a non-digit character</pre><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_whitespace.asp">\s</a> =&gt;Find a whitespace character</pre><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_whitespace_non.asp">\S</a> =&gt;Find a non-whitespace character</pre><pre><a href="https://www.w3schools.com/jsref/jsref_regexp_begin.asp">\b</a> =&gt;Find a match at the beginning/end of a word, beginning like this: \bHI, end like this: HI\b</pre><p><strong>8) readline():</strong></p><p><strong>Readline function</strong> is their method to read stdin and print() is the stdout method.</p><p><strong>var</strong> name = readline();</p><p><strong>9)Array.sort():</strong></p><p>arr.sort() function is used to sort the array.</p><pre>var nums =[2,9,3,8,9,8,6,4]</pre><pre>nums = nums.sort();</pre><pre>console.log(nums);</pre><pre>//output: [2,3,4,6,8,8,9,9]</pre><p><strong>10)throw():</strong></p><p>The <strong>throw statement</strong> throws a user-defined exception<strong>.</strong></p><p>Example:</p><pre>if( conditions === true){</pre><pre>///execute this code</pre><pre>}</pre><pre>else{</pre><pre>throw(new Error(“error message”))</pre><pre>}</pre><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35f0688c5bee" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>