<?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: pranav589</title>
    <description>The latest articles on DEV Community by pranav589 (@pranav589).</description>
    <link>https://dev.to/pranav589</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%2F522302%2Fd74873b1-c0a7-4ebb-b41b-8c3e78140ae8.jpeg</url>
      <title>DEV Community: pranav589</title>
      <link>https://dev.to/pranav589</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pranav589"/>
    <language>en</language>
    <item>
      <title>Day-2: 30 days of code- Hackerrank</title>
      <dc:creator>pranav589</dc:creator>
      <pubDate>Fri, 25 Dec 2020 15:34:36 +0000</pubDate>
      <link>https://dev.to/pranav589/day-2-30-days-of-code-hackerrank-kcj</link>
      <guid>https://dev.to/pranav589/day-2-30-days-of-code-hackerrank-kcj</guid>
      <description>&lt;p&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%2Fi%2Flmsgechbhgpb36l5y4tq.jpg" 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%2Fi%2Flmsgechbhgpb36l5y4tq.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hey folks. On Day-2 of 30-Days of Code by HackerRank, we'll solve the question related to operators using Javascript.&lt;/p&gt;

&lt;p&gt;Lets dive into it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Day-0
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Task:-
&lt;/h4&gt;

&lt;p&gt;'Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost. Round the result to the nearest integer.'&lt;/p&gt;

&lt;p&gt;In the task, we are given the meal price, tip percent and tax percent and we have to find the total cost of the meal which would be the addition of this three things(meal+tip+tax).&lt;/p&gt;

&lt;h4&gt;
  
  
  Solution:-
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;solve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;meal_cost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tip_percent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tax_percent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;//total cost equation basic maths&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;meal_cost&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tip_percent&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nx"&gt;meal_cost&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tax_percent&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nx"&gt;meal_cost&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;//rounding the value to the nearest integer using Math.round&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rounded_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;total_cost&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rounded_cost&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;h4&gt;
  
  
  Explanation:-
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;In the solution, we wrote a function solve(), which receives three parameters viz., meal_cost, tip_percent, tax_percent.
The function call for solve() is already made for us and we just have to complete the code inside the function.&lt;/li&gt;
&lt;li&gt;Now, we declared a variable called as total_cost and assigned a simple mathematical equation to it to give the total meal cost.&lt;/li&gt;
&lt;li&gt;Then we rounded off our total meal cost to the nearest integer using Math.round() method (which is a built-in method of javascript).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you!! Stay tuned!!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>help</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Day-1: 30 days of code- Hackerrank</title>
      <dc:creator>pranav589</dc:creator>
      <pubDate>Thu, 24 Dec 2020 13:00:26 +0000</pubDate>
      <link>https://dev.to/pranav589/day-1-30-days-of-code-hackerrank-19nc</link>
      <guid>https://dev.to/pranav589/day-1-30-days-of-code-hackerrank-19nc</guid>
      <description>&lt;p&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%2Fi%2Flmsgechbhgpb36l5y4tq.jpg" 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%2Fi%2Flmsgechbhgpb36l5y4tq.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello guys!! Continuing the 30 days of code challenge by hackerrank using javascript, today we are solving the question related to 'data types'.&lt;/p&gt;

&lt;p&gt;What are different types??&lt;/p&gt;

&lt;p&gt;Data can be of different types like Strings, Numbers, Arrays, Objects, etc. &lt;/p&gt;

&lt;p&gt;Lets dive into the solution. &lt;/p&gt;

&lt;h3&gt;
  
  
  Day-1
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Task:-
&lt;/h4&gt;

&lt;p&gt;'Complete the code in the editor below. The variables i,d ,s and are already declared and initialized for you. You must:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declare 3 variables: one of type int, one of type double, and one of type String.&lt;/li&gt;
&lt;li&gt;Read 3 lines of input from stdin (according to the sequence given in the Input Format section below) and initialize your 3 variables.&lt;/li&gt;
&lt;li&gt;Use the + operator to perform the following operations:

&lt;ul&gt;
&lt;li&gt;Print the sum of i plus your int variable on a new line.&lt;/li&gt;
&lt;li&gt;Print the sum of d plus your double variable to a scale of one decimal place on a new line.&lt;/li&gt;
&lt;li&gt;Concatenate s with the string you read as input and print the result on a new line.'&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  Solution:-
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;4.0&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;HackerRank &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="c1"&gt;// Declare second integer, double, and String variables.&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;
    &lt;span class="c1"&gt;// Read and save an integer, double, and String to your variables.&lt;/span&gt;
    &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=+&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;readLine&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=+&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;readLine&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;readLine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="c1"&gt;// Print the sum of both integer variables on a new line.&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Print the sum of the double variables on a new line.&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="c1"&gt;// Concatenate and print the String variables on a new line&lt;/span&gt;
    &lt;span class="c1"&gt;// The 's' variable above should be printed first.&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;c&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;h4&gt;
  
  
  Explanation:-
&lt;/h4&gt;

&lt;p&gt;Initially some variables are already declared and initialized for us.(i, d, s)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Here we have declared our variables(a, b, c)
a=integer
b=double
c=string&lt;/li&gt;
&lt;li&gt;Then we read the input given by the user using 
readLine() function and store it into the 
variables that we have declared above i.e., a, 
b, c.&lt;/li&gt;
&lt;li&gt;As specified in the task, we have to do sum of 
the two integers i.e., i and a.&lt;/li&gt;
&lt;li&gt;Then we add d and b. Here we have used a 
toFixed() method. By using the method, we can 
specify the number of decimals we want.&lt;/li&gt;
&lt;li&gt;And the last task is to concatenate the strings 
using the + operator.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Topics Covered:-
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Data types&lt;/li&gt;
&lt;li&gt;Concatenation&lt;/li&gt;
&lt;li&gt;Declaring variables and assigning values to it.&lt;/li&gt;
&lt;li&gt;toFixed() method&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you guys !!! Stay tuned!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Day-0: 30 days of code- Hackerrank</title>
      <dc:creator>pranav589</dc:creator>
      <pubDate>Wed, 23 Dec 2020 15:52:38 +0000</pubDate>
      <link>https://dev.to/pranav589/day-0-30-days-of-code-hackerrank-35m9</link>
      <guid>https://dev.to/pranav589/day-0-30-days-of-code-hackerrank-35m9</guid>
      <description>&lt;p&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%2Fi%2Flmsgechbhgpb36l5y4tq.jpg" 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%2Fi%2Flmsgechbhgpb36l5y4tq.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello guys. I have started to solve the 30 days of code challenge on HackerRank using javascript. I'm gonna post the solutions of all the challenges with some key points to understand the solution.&lt;br&gt;
So let's get started.&lt;/p&gt;

&lt;h3&gt;
  
  
  Day-0
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Task:-
&lt;/h4&gt;

&lt;p&gt;'To complete this challenge, you must save a line of input from stdin to a variable, print Hello, World. on a single line, and finally print the value of your variable on a second line.'&lt;/p&gt;

&lt;h4&gt;
  
  
  Solution:-
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;processData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inputString&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// This line of code prints the first line of output&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, World.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Write the second line of output that prints the contents of 'inputString' here.&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inputString&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;h4&gt;
  
  
  Explanation:-
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Here just the basic console logs are used.&lt;/li&gt;
&lt;li&gt;The second console log prints the content in the 'inputString' which is given as a parameter to the function.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you!! Stay tuned!!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>help</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
