<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nikhil Dhawan</title>
    <description>The latest articles on DEV Community by Nikhil Dhawan (@nikhildhawan).</description>
    <link>https://dev.to/nikhildhawan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F639927%2F5e967df5-cbb4-4158-9c98-ccb7daf293d3.jpg</url>
      <title>DEV Community: Nikhil Dhawan</title>
      <link>https://dev.to/nikhildhawan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikhildhawan"/>
    <language>en</language>
    <item>
      <title>Machine Learning - Regression- Simple Linear Regression</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Mon, 08 Jan 2024 08:23:06 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/machine-learning-regression-simple-linear-regression-241m</link>
      <guid>https://dev.to/nikhildhawan/machine-learning-regression-simple-linear-regression-241m</guid>
      <description>&lt;p&gt;Hi all in this post we will see how we can train &lt;strong&gt;Simple Linear regression&lt;/strong&gt; model. After we are done with preprocessing of data we can direct train our model with help of LinearRegression from sklearn linearmodel. First we train and then predict the testing values that will help to see how good our model is. To train we use fir method on &lt;strong&gt;LinearReression&lt;/strong&gt; and using predict method on the same for testing data.&lt;br&gt;
Before we move to code, let me tell you some BTS for SLR, our data is of shape as below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jiYivlkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tgrl5b2j0knazblsbky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jiYivlkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tgrl5b2j0knazblsbky.png" alt="Image1" width="350" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so here we have salary for the years of experience and we have to make a mode to be able to predict salary in future based on years we input in model. SLR is usually depicted as:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yh= bo + b1X1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;where yh is dependent variable, bo is y-intercept and is constant, b1 is slope co-officient and X1 is independent variable&lt;/p&gt;

&lt;p&gt;Model tries to find best slope line such that we have ordinary least squares (sum of (y1-yh)^2 is minimized)&lt;/p&gt;

&lt;p&gt;Let's move to code part&lt;/p&gt;

&lt;p&gt;Training the model&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Predicting the test results&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;y_pred = regressor.predict(X_test)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets now visualize the plot for training set, for that we use pyplot from matplotlib&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plt.scatter(X_train, y_train, color = 'red')
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
plt.title('Salary vs Experience (Training set)')
plt.xlabel('Years of Experience')
plt.ylabel('Salary')
plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FnCOKm4R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjkggpkyg82fg1auj60p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FnCOKm4R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjkggpkyg82fg1auj60p.png" alt="Image2" width="442" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Plot for Test set&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plt.scatter(X_test, y_test, color = 'red')
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
plt.title('Salary vs Experience (Test set)')
plt.xlabel('Years of Experience')
plt.ylabel('Salary')
plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2KMKlsbW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wb3gpfov9wastj69y80.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2KMKlsbW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wb3gpfov9wastj69y80.png" alt="Image3" width="454" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here if we see closely we are using plot line same for both , that's because the slope line will be same for both as the model we used will use same predictor while predicting values for unknown values, even if you change that to X_test it should be same. Red dots in second graph shows actual values we have in data and values along line will be predicted values, and we can see most of the points are overlapping but some are not. No model can be 100% fitting.&lt;/p&gt;

&lt;p&gt;Thanks for reading, hope it was useful ,see you next time&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Machine Learning - Data Preprocessing-2 label encoder, Splitting Data and Feature scaling</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Sun, 07 Jan 2024 07:31:03 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/machine-learning-data-preprocessing-2-label-encoder-splitting-data-and-feature-scaling-4g6c</link>
      <guid>https://dev.to/nikhildhawan/machine-learning-data-preprocessing-2-label-encoder-splitting-data-and-feature-scaling-4g6c</guid>
      <description>&lt;p&gt;H all, So in this article we will discuss about  &lt;strong&gt;label encoder&lt;/strong&gt;, &lt;strong&gt;splitting data set&lt;/strong&gt; and then &lt;strong&gt;feature scaling&lt;/strong&gt; it.&lt;br&gt;
So let's start with &lt;strong&gt;label encoder&lt;/strong&gt; these are basically used for encoding dependent variable which is Y here. so in data set we have values like yes or no , that will be encoded to numeric values of 0 or 1. We will use LablelEncoder from sklearn preprocessing and then transform the data as below&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from sklearn.preprocessing import LabelEncoder&lt;br&gt;
le = LabelEncoder()&lt;br&gt;
y = le.fit_transform(y)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After we are done with this we can now &lt;strong&gt;split the data&lt;/strong&gt; into Training and Test sets. Generally we keep 80% of data as training and rest as test set. It is useful for evaluating model performance once we are done training the model. This can be done via train_test_split from sklearn model_selection&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from sklearn.model_selection import train_test_split&lt;br&gt;
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once we have got 2 sets of data if our data needs to &lt;strong&gt;Feature scaling&lt;/strong&gt; we will perform that using Standard Scaler from sklearn preprocessing . Here we use mostly Standardization method for Feature Scaling, there is also another method which is called normalization but mostly standardization is used. We will first scale training data and then using same scaling parameters test set will be scaled. It is recommended and general practice to scale after data splitting as test data should be unseen data to the model and if we split after scaling it will have data bias and our model might not perform in the way we intend.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from sklearn.preprocessing import StandardScaler&lt;br&gt;
sc = StandardScaler()&lt;br&gt;
X_train = sc.fit_transform(X_train)&lt;br&gt;
X_test = sc.transform(X_test)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we have transformed data after preprocessing and ready to develop our models to predict values. We will cover it in future articles.&lt;/p&gt;

&lt;p&gt;Hope it helped.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Machine Learning - Data Preprocessing- 1</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Sat, 06 Jan 2024 07:04:55 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/machine-learning-data-preprocessing-1-afn</link>
      <guid>https://dev.to/nikhildhawan/machine-learning-data-preprocessing-1-afn</guid>
      <description>&lt;p&gt;Hi all, in this article we will discuss about the first step to building our model - &lt;strong&gt;Data Preprocessing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Importing Libraries&lt;/strong&gt; - In this we import most common used libraries like pandas, numpy . There might be others also but for this example lets keep it as it&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import numpy as np&lt;br&gt;
import pandas as pd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Importing Datasets&lt;/strong&gt; - for this example we have a dataset that is as below containing data if a purchase was made or not from a specific person having particular identity&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mtT2FUC4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9eckhiwfodh7ip6lu7p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mtT2FUC4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9eckhiwfodh7ip6lu7p.png" alt="Image description" width="314" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this data we can see first 3 columns are features and last is the dependent variable . We mostly divide our data using this only, with X as the inputs and y as the output and are loaded using pandas and then divided using iloc operation on dataset&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dataset = pd.read_csv('Data.csv')&lt;br&gt;
X = dataset.iloc[:, :-1].values&lt;br&gt;
y = dataset.iloc[:, -1].values&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So now we have our data separated and ready for further handling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling missing data&lt;/strong&gt;- So if you see the data we have 2 missing data (marked in yellow)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6KXp_w9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5joo1sc3jfo8nvf6eav6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6KXp_w9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5joo1sc3jfo8nvf6eav6.png" alt="Image description" width="325" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most broadly used library for data science operations is sklearn. So in this case also we will use it only. Strategy for this will be replacing the empty data with average value from the column and to use it SimpleImputer from sklearn impute is used&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from sklearn.impute import SimpleImputer&lt;br&gt;
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')&lt;br&gt;
imputer.fit(X[:, 1:3])&lt;br&gt;
X[:, 1:3] = imputer.transform(X[:, 1:3])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and it will give us &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4cE36qsJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wsjcyu9zbtrwd86d93z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4cE36qsJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wsjcyu9zbtrwd86d93z.png" alt="Image description" width="379" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One more thing to take care here is first column that has text/string values, as models might not be able to interpret these correctly we also need to encode this to digits to be able to feed them to model.&lt;br&gt;
For this ColumnTransformer is used from sklearn compose and OneHotEncoder from sklearn preprocessing&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from sklearn.compose import ColumnTransformer&lt;br&gt;
from sklearn.preprocessing import OneHotEncoder&lt;br&gt;
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [0])], remainder='passthrough')&lt;br&gt;
X = np.array(ct.fit_transform(X))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this ColumnTransformer takes input as transformers that is tupple which has name of transformer, transformer itself and column to transform and remainder is to specify what to do for other columns, which here is passthrough which mean no change in other columns.&lt;br&gt;
and our output will be&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jf5UMlad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y0rkd2v2eegvq82fmv5t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jf5UMlad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y0rkd2v2eegvq82fmv5t.png" alt="Image description" width="349" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope it was helpful. In this next part of preprocessing we will see how to encode labels, Feature scaling and spliting data into training and test set.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Machine Learning - The start</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Fri, 05 Jan 2024 08:09:46 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/machine-learning-the-start-14an</link>
      <guid>https://dev.to/nikhildhawan/machine-learning-the-start-14an</guid>
      <description>&lt;p&gt;Hi all, with article i start with learning process of machine learning and AI from very beginning. Lets start from The Machine learning process:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Pre-processing&lt;/strong&gt; - This is the starting phase of almost all the new models we build. it mostly has the below common processes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Importing the data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cleaning the data -&amp;gt; In this we take care of various things like missing data, need of normalization or standardization based on our requirement, encoding categories or labels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Splitting the data into training and test sets -&amp;gt; Generally we split our data into 2 sets in which 80% is kept as training set on which our model is trained and 20% is test set on which performance or efficiency of our model is measured.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Modelling&lt;/strong&gt; - In this actual model is build from already present models or ensemble(combination of models) and has the below stages mainly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Build&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Train - Our training data set is fed into the model based on which our model gets trained&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make predictions - Based on training data we are ready to make predictions for unknown data set&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Evaluation&lt;/strong&gt; - In this step performance is measured for the model we have built and once we are satisfied with the results we make future predictions using and if not satisfied we repeat the above steps again as its mostly some models work great on some sets of data and some may not perform well .&lt;/p&gt;

&lt;p&gt;Hope it give you simple overview of the process, see you next time.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Search text and navigate -Chrome alike feature with marker locations using Angular</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Sun, 23 Jan 2022 03:45:18 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/search-text-and-navigate-chrome-alike-feature-with-marker-locations-using-angular-1a67</link>
      <guid>https://dev.to/playfulprogramming-angular/search-text-and-navigate-chrome-alike-feature-with-marker-locations-using-angular-1a67</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@aaronburden?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Aaron Burden&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/highlight-webite?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi All, this post is in continuation with my last post in which we have learned how to highlight text from user input, if you haven't read that you can refer to it at &lt;a href="https://dev.to/this-is-angular/search-and-highlight-text-feature-using-angular-l98"&gt;https://dev.to/this-is-angular/search-and-highlight-text-feature-using-angular-l98&lt;/a&gt; as it is our starting part of today's task where we will make Chrome alike search and navigate feature.&lt;/p&gt;

&lt;p&gt;Our basic code will remain the same, now we will have a bar on the right on which we will show the location as per scroller for helping to move to highlighted text from scroll bar also with arrows to navigate between those. Let us make 1 marker bar on the right side based upon the container height the location from the top, which we can get as below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;marker&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;markerTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;ViewChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;textContainer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;textContainer&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;ElementRef&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;ngAfterContentInit&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;textContainerRect&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nativeElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBoundingClientRect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;markerHeight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;textContainerRect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;markerTop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;textContainerRect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;top&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;*ngIf=&lt;/span&gt;&lt;span class="s"&gt;"markerHeight&amp;gt;0 &amp;amp;&amp;amp;markerTop&amp;gt;0 "&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"marker"&lt;/span&gt; &lt;span class="na"&gt;[ngStyle]=&lt;/span&gt;&lt;span class="s"&gt;"{'height':markerHeight+'px','top':markerTop+'px'}"&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now what we have on the screen is &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faeizo3xzkfh1s8s4dtnh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faeizo3xzkfh1s8s4dtnh.png" alt=" " width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now we will find a way to get the location of the highlighted text based upon the class which we attached to each highlighted text which is highlighted-text in our case, which you can choose as per your choice. We will build a function that we can call after highlights are done and save the location in an array with which we can make the ticks on the bar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;getMarkerTicks&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchElements&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nativeElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.highlighted-text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;markerTicks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;


        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;markerTicks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;markerHeight&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollHeight&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
            &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBoundingClientRect&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;top&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nativeElement&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.highlighted-text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrollIntoView&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;block&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;behavior&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;smooth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And corresponding to it we can have html to create ticks as per number of highlights we have.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"markersTicks"&lt;/span&gt; &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let m of markerTicks"&lt;/span&gt; &lt;span class="na"&gt;[ngStyle]=&lt;/span&gt;&lt;span class="s"&gt;"{'top':m+'px'}"&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need now the way to show total number of highlights and navigator buttons, for which i will use disabled input and 2 arrow buttons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"input-navigator"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;disabled&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"{{ activeIndex + ' of '+  markerTicks.length}}"&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-btns"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-btn"&lt;/span&gt; &lt;span class="na"&gt;(click)=&lt;/span&gt;&lt;span class="s"&gt;"moveToNext()"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"../assets/down-arrow.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;  &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-btn"&lt;/span&gt; &lt;span class="na"&gt;(click)=&lt;/span&gt;&lt;span class="s"&gt;"moveToBack()"&lt;/span&gt;  &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"../assets/up-arrow.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For buttons functionality we need to have functions to perform the said actions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;moveToNext&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;highlightedSpans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nativeElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.highlighted-text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;highlightedSpans&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;highlightedSpans&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchElements&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;moveToBack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;highlightedSpans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nativeElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.highlighted-text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;highlightedSpans&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;highlightedSpans&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchElements&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activeIndex&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we are done with a fully functional app for searching and navigating between them.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftb78x93s4ygrqaitdvo1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftb78x93s4ygrqaitdvo1.png" alt="done screen" width="800" height="304"&gt;&lt;/a&gt;&lt;br&gt;
Full code can be found at &lt;a href="https://github.com/nikhild64/highlight-text-navigator" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;br&gt;
You can play with it on &lt;a href="https://nikhild64.github.io/highlight-text-navigator/" rel="noopener noreferrer"&gt;https://nikhild64.github.io/highlight-text-navigator/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you liked it please share it with your friends or if any suggestions reach me out on &lt;a href="https://twitter.com/nikhild64" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or comment below.&lt;br&gt;
Till next time Happy Learning!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>angular</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Search and Highlight Text feature using Angular</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Thu, 20 Jan 2022 15:00:07 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/search-and-highlight-text-feature-using-angular-l98</link>
      <guid>https://dev.to/playfulprogramming-angular/search-and-highlight-text-feature-using-angular-l98</guid>
      <description>&lt;p&gt;Cover Photo by &lt;a href="https://unsplash.com/@aaronburden?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Aaron Burden&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/search-and-highlight?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi all, in today's post we will discuss how we can make an app search and highlight features in our angular app. So the scenario can be we have a long text and we have to give the user functionality to search in a text box and related text to highlight on the paragraph below.&lt;/p&gt;

&lt;p&gt;For this we need to have a simple setup, a search box, and a text in which we want to search(here I will take some dummy text) like as below:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F895crge1ahjgd4dpbdse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F895crge1ahjgd4dpbdse.png" alt="Start screen" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the input lets bind that to ngModel which we will use as search criteria and a div having sample text as an innerHtml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"search-input"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Search here: &lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;[(ngModel)]=&lt;/span&gt;&lt;span class="s"&gt;"searchText"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"search"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-contaniner"&lt;/span&gt; &lt;span class="na"&gt;[innerHtml]=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;  &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;searchText&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;`somedummy text here`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For functionality of highlighting we will need to create an Angular pipe which I am naming as a highlighter, we can create a pipe using Angular CLI using the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;ng g pipe highlighter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can put the below code in the pipe if we want to have border limit on the search&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;re&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RegExp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;b(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;b)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;igm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;span class="highlighted-text"&amp;gt;$1&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and if we want to have text to searched irrespective of the word boundary , we can use below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;re&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RegExp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;b(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;b)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;igm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;span class="highlighted-text"&amp;gt;$&amp;amp;&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets add 1 more input where we utilize this partial highlighting also and combine these 2 pipes into 1 pipe based upon purpose, which makes our pipe code as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;===&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;full&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;re&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RegExp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;b(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;b)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;igm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;span class="highlighted-text"&amp;gt;$1&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;re&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RegExp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;igm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;span class="highlighted-text"&amp;gt;$&amp;amp;&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And after adding 2 inputs our UI will look like this.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frj2ku05jo40yro3m99vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frj2ku05jo40yro3m99vg.png" alt="2inputs screen" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now lets integrate our code with pipe and test it out. In HTML we can add the pipe to text we added with the input as input from user and with search criteria.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-contaniner"&lt;/span&gt; &lt;span class="na"&gt;[innerHtml]=&lt;/span&gt;&lt;span class="s"&gt;"text | highlighter:searchText:'full'"&lt;/span&gt;  &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Full code can be found at &lt;a href="https://github.com/nikhild64/highlight-text" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;br&gt;
Now let us test it out, we will be able to see the text is getting highlighted in both ways and should be as below, you can also try it out at &lt;a href="https://nikhild64.github.io/highlight-text/" rel="noopener noreferrer"&gt;https://nikhild64.github.io/highlight-text/&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb5s1ngbixlxevzna0z7e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb5s1ngbixlxevzna0z7e.png" alt="working example" width="800" height="235"&gt;&lt;/a&gt;&lt;br&gt;
Hope you liked it and if you have some other ways you might have used it, please comment below.&lt;br&gt;
If you liked it please share it with your friends or if any suggestions reach me out on &lt;a href="https://twitter.com/nikhild64" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or comment below.&lt;br&gt;
Till next time Happy Learning!&lt;br&gt;
&lt;iframe src="https://stackblitz.com/edit/highlighttext-angular?view=preview" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Blockchain - Writing our first Smart Contract</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Wed, 22 Dec 2021 06:58:52 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/blockchain-writing-our-first-smart-contract-mib</link>
      <guid>https://dev.to/nikhildhawan/blockchain-writing-our-first-smart-contract-mib</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@peiobty?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Pierre Borthiry&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/smart-contracts?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi all, in this article we will start writing our first smart contract based on Ethereum in Solidity. In the last few articles, we discussed blockchain and its various terminology.&lt;/p&gt;

&lt;p&gt;So for writing our smart contract we will be using an online code editor &lt;a href="https://remix.ethereum.org/" rel="noopener noreferrer"&gt;Remix&lt;/a&gt; with which we can quickly write our contract and test that out in the web browser itself without any local setup. We will also do some local setup in upcoming articles, But in this let us just try to understand important aspects of smart contract and solidity. So if you are familiar with JavaScript it would be easy for you to grasp solidity.&lt;br&gt;
Once you open &lt;a href="https://remix.ethereum.org/" rel="noopener noreferrer"&gt;Remix&lt;/a&gt;, you will be able to see the left panel from that you can navigate to contracts and open Ballot. sol file. Sol is the file extension for the solidity contract.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kugfawgqlf85tvu4l2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kugfawgqlf85tvu4l2f.png" alt="Remix screenshot left Nav"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To start with you can copy-paste the below code in the editor and then I will explain this line by line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pragma solidity ^0.4.17;

contract Inbox{
    string private message;
    function Inbox(string initialmsg) public{
        message=initialmsg;
    }
    function setMsg(string newmsg) public{
        message=newmsg;
    }
    function getMsg() public view returns (string){
        return message;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this we are using solidity version 0.4.17, you can verify if the remix is using the same version of this or not avoid any complication error as per the image below.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55kzuu57mwhbut959n52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55kzuu57mwhbut959n52.png" alt="version check"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's understand the code and its functioning, this might feel familiar to you with JavaScript.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbx5ucmt4mpex3h87ts0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbx5ucmt4mpex3h87ts0g.png" alt="Code explaination"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can deploy this contract inside remix to do that left nav button which is as below.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmi4kkmjicj89m8grtwfz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmi4kkmjicj89m8grtwfz.png" alt="deploy button"&gt;&lt;/a&gt;&lt;br&gt;
Now make sure in this tab JavaScript VM is selected, and you might see you have some 100 test ethers for this environment and make sure our file is selected in contract input.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fetude8cc0pwp992ly8gg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fetude8cc0pwp992ly8gg.png" alt="contract deploy"&gt;&lt;/a&gt;&lt;br&gt;
Now you can set some initial value and click on deploy. You will notice a new contract in the below section.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbd2gb3yi7twnnp3m660.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbd2gb3yi7twnnp3m660.png" alt="contract deployed"&gt;&lt;/a&gt;&lt;br&gt;
One more interesting thing to notice here is the amount of ether in the account selected above.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqs1sfsin7l8rgnx5cuu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqs1sfsin7l8rgnx5cuu0.png" alt="decreased ether"&gt;&lt;/a&gt;&lt;br&gt;
Now with this, we can understand that deploying contracts over the network blockchain involves some charges. YOu can now play around with the contract you deployed by retrieving and setting new messages.&lt;br&gt;
Please let me know in case of any doubts.&lt;/p&gt;

</description>
      <category>blockchain</category>
    </item>
    <item>
      <title>Blockchain - How are transactions carried out?</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Mon, 13 Dec 2021 14:53:23 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/blockchain-how-are-transactions-carried-out-1bc9</link>
      <guid>https://dev.to/nikhildhawan/blockchain-how-are-transactions-carried-out-1bc9</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@clintadair?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Clint Adair&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/blockchain?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;br&gt;
Hi readers, in this article we will discuss how are the transactions started and carried out for the new transaction and the steps involved in it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Once you submit any transaction, a backend call is made with the address details.&lt;/li&gt;
&lt;li&gt;A transaction object is created at the backend using web3.js which includes the below details:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;nonce: It is usually called a number only used once.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;to: The to address which is the receiver.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;value: The amount which is to be sent from sender to receiver.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;gasPrice : Amount of Wei user is willing to pay for transaction. Wei is the smaller unit of ether. 1 ETH = 1,000,000,000,000,000,000 wei.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;gas limit: Maximum units of gas this transaction can consume.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;v,r,s:  these 3 pieces of information are the cryptographic data. this can be used to generate the sender's account address by the sender's private key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So in our case as we will be using the Rinkbey Test network in this series, this transaction object is sent to that network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now there is a wait time involved in this request to receive the response, which is block time(you can refer to previous articles to terms).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the block is added success message is received.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So this concludes our steps involved in the transaction. In the next article, we will create our first smart contract on the test network.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Starting journey toward building Blockchain App</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Sun, 12 Dec 2021 15:44:43 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/starting-journey-toward-building-blockchain-app-2c33</link>
      <guid>https://dev.to/nikhildhawan/starting-journey-toward-building-blockchain-app-2c33</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@zoltantasi?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Zoltan Tasi&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/ethereum?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi all, in this article, we will discuss the path toward building our DAP (Decentralized Applications) using blockchain specifically based upon Ethereum. &lt;/p&gt;

&lt;p&gt;So when Ethereum was launched it was kept in mind that it will help make Dap's and nowadays it's a famous cryptocurrency and it can also be used to transfer data based upon blockchain technology. There are many networks involved in the overall ecosystem and each network has 1 or more nodes and each node is running an Ethereum client. Each node has a full copy of an identical blockchain.&lt;/p&gt;

&lt;p&gt;For end consumers, there are wallets from which they can access their wallets and carry out transactions e.g. we have chrome extension Metamask and developers use web3.js. You can install Metamask in your chrome form &lt;a href="https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For our journey toward building our App, we will use the Rinkeby Test network of Ethereum which help us to test out our transactions without burning real cash.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XqApQAEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqcrxxsslltorei84lgj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XqApQAEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqcrxxsslltorei84lgj.png" alt="Metamask Wallet" width="880" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we see here we have an account address that is unique to a user and will be the same across different networks. For getting free ETH in your test account to the address you get in your wallet you can use &lt;a href="https://faucets.chain.link/"&gt;https://faucets.chain.link/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RlCOlM2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwm8zba5qxm0n7xx8qzb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RlCOlM2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwm8zba5qxm0n7xx8qzb.png" alt="Faucets" width="880" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These tokens don't have any real value but can be used in testing our smart contract codes for free before we make them usable on the main ETH network.&lt;br&gt;
The account address we see on the wallet is our public address(can be referred to as an email address for understanding) which we can use to receive or send ETH tokens and there are 2 other keys involved with it Public and Private key which combined to act as an identifier for our account to carry out the transaction.&lt;/p&gt;

&lt;p&gt;Thanks for reading this. In upcoming articles in this series, we will continue our journey to learn more and discuss how is the transaction carried out and important pointers in that.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>technology</category>
    </item>
    <item>
      <title>Blockchain - Commonly used terms</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Sat, 11 Dec 2021 16:41:29 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/blockchain-commonly-used-terms-1bl2</link>
      <guid>https://dev.to/nikhildhawan/blockchain-commonly-used-terms-1bl2</guid>
      <description>&lt;p&gt;Hi all, in this article, we will try to cover some of the terms which are very helpful in understanding blockchain technology better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Block Time&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Block time refers to the time it takes for adding new data to the existing network. This time taken by the blockchain network is mainly the time it takes to validate the hash of that data to some predefined value. Like for example for Bitcoin, this time is around 10 mins and for Ethereum it is around 15 seconds which depicts that it is fast to add data on ETH than BTC. To see the average Block time for Ethereum over time you can refer to &lt;a href="https://etherscan.io/chart/blocktime"&gt;https://etherscan.io/chart/blocktime&lt;/a&gt; .&lt;br&gt;
Average Block time of ETH over time&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Smart Contract&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Smart contracts are accounts controlled by the code. They tell how incoming and outgoing requests are to be handled without the intervention of any other party involvement, that is the reason the blockchain cryptocurrencies are referred to as decentralized banking systems. This is the case of Ethereum has below information:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Code: Raw machine code for this contract.&lt;/li&gt;
&lt;li&gt;Storage: Data storage of contract.&lt;/li&gt;
&lt;li&gt;Balance: Amount of Ether.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Hash Functions&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
These are the functions that are used to convert input data into encrypted values of a certain length and the same data will always produce the same output. It is not possible to get the original data from the hash outputs which makes it important for blockchains for higher security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Proof of Work&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
It is how some computations are done by the network nodes to get to the hash output for the certain matching predefined criteria before the block is added to the network. Doing this makes use of resources of computer i.e. work, hence the person who is lending these resources are called minors and is given some rewards in return for this. Bitcoin uses this method to add new transactions blocks to the network. But this method involves higher energy consumption.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Proof of Stake&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
Proof of stake was developed as an alternative to the Proof of Work. In this, the miner can only mine once he has put his/her coins on the stake and can only mine the max of the coins that are on stake. So this solves the issue of higher power consumption that is there is a POW. Ethereum as of now uses both POS and POW and is planning to completely move toward POS.&lt;/p&gt;

&lt;p&gt;Thanks for reading this article, in upcoming articles we will discuss more on blockchain technology.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>technology</category>
    </item>
    <item>
      <title>Blockchain- An Introduction</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Fri, 10 Dec 2021 13:59:08 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/blockchain-an-introduction-52k6</link>
      <guid>https://dev.to/nikhildhawan/blockchain-an-introduction-52k6</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@thoughtcatalog?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Thought Catalog&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/blockchain?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi all, In the upcoming series of articles we will discuss what blockchain is and what are the ways we can get into building our apps based upon this technology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blockchain &lt;/strong&gt;is a technology in simple words helps to make some irreversible transactions or the block of data. So thinking in this way makes it the secure way of storing data than the databases. It works in this way like we have a chain of data 1 behind the other and the front data node has the address of the node which is behind it and the 1 in front and has its hash key which is SHA256 hash and is like a digital fingerprint of that data, so if you make some changes in the data that changes the hash key and makes it as out of sync from the other blocks.&lt;/p&gt;

&lt;p&gt;To make it in sync we might think we will change the hash addresses in other nodes but that would be an easy task to do for when there are millions of nodes, moreover here we are talking about only 1 network that has a copy of node data, but in actual blockchain, we have many copies of same data and the data to be modified on network copies is not that easy and if on some network it is found data to be mismatched that will not be modified anyhow as blockchain as the technology works on proof of work concepts.&lt;br&gt;
We will discuss blockchain terms more in upcoming articles alongside learning to build apps based upon blockchain&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>technology</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Resource Helper website for easy access to daily usable links</title>
      <dc:creator>Nikhil Dhawan</dc:creator>
      <pubDate>Mon, 06 Sep 2021 14:27:43 +0000</pubDate>
      <link>https://dev.to/nikhildhawan/resource-helper-website-for-easy-access-to-daily-usable-links-19n</link>
      <guid>https://dev.to/nikhildhawan/resource-helper-website-for-easy-access-to-daily-usable-links-19n</guid>
      <description>&lt;p&gt;Hi all, &lt;/p&gt;

&lt;p&gt;I am happy to announce the Resource Helper website, which I have been working on for the last 2 weeks. The link is &lt;a href="https://reshelper.netlify.app/"&gt;https://reshelper.netlify.app/&lt;/a&gt; .&lt;br&gt;
I thought to make an app like this because many a time we need to go through google for simple links again and again and sometimes we even bookmark them but it gets lost in the huge list. You can also add your links on the website which you think might be helpful. I will make this GitHub repo public in a week as I need to check some more things. If you have any suggestions for improvement please let me know.&lt;br&gt;
If you liked the concept please share it in your network so that it is helpful for more people.&lt;/p&gt;

</description>
      <category>resources</category>
      <category>learning</category>
      <category>sharing</category>
    </item>
  </channel>
</rss>
