Data Types HackerRank Solution| Amazing 10 Days of JavaScript

Day 0: Data Types HackerRank Solution| Amazing 10 Days of JavaScript

10 Days of JavaScript|Day 0: Data Types HackerRank Solution

Hello programmers, today we are sharing proper solutions with all test cases passed of 10 Days of JavaScript by HackerRank.

As you all know JavaScript is the most popular and the most challenging programming language to conquer but nowadays it’s not. There are some amazing platforms where they provide challenges on different languages and HackerRank is one of them.

So in this Day0: Data Types HackerRank Solution we will discuss how we can solve this problem very easily. Simply what you have to do is you have given some variables and with the help of the + operator you have to convert them to integer and then sum.

Before checking out the solution it’s highly recommended to do it by yourself first because these challenges will help you to think about how to deal with these real-world problems.

Let’s get started.

Here are a couple of related posts you may find helpful, too:

  1. How to make money through coding? 9 Easy Ways To Make Money.
  2. 15+FREE Stuff For College Students Using Your College ID.
  3. how to get rich by coding? I make $100 every month from coding

Problem: Data Types in Javascript

10 days of JavaScript

Overview: 10 Days of JavaScript

This series focuses on learning and practicing JavaScript. Each challenge comes with a tutorial article, and you can view these articles by clicking either the Topics tab along the top of the article icon in the right-hand menu.

Objective

Today, we’re discussing data types. Check out the attached tutorial for more details.

Task

Variables named firstInteger, firstDecimal, and firstString are declared for you in the editor below. You must use the + operator to perform the following sequence of operations:

  1. Convert secondInteger to an integer (Number type), then sum it with firstInteger and print the result on a new line using console.log.
  2. Convert secondDecimal to a floating-point number (Number type), then sum it with firstDecimal and print the result on a new line using console.log.
  3. Print the concatenation of firstString and secondString on a new line using console.log. Note that firstString must be printed first.

Input Format

Data TypeParameterDescription
stringsecondIntegerThe string representation of an integer you must sum with firstInteger.
stringsecondDecimalThe string representation of a floating-point number you must sum with firstDecimal.
stringsecondStringA string of one or more space-separated words you must append to secondString.

Output Format

Print the following three lines of output:

  1. On the first line, print the sum of firstInteger and the integer representation of secondInteger.
  2. On the second line, print the sum of firstDecimal and the floating-point representation of secondDecimal.
  3. On the third line, print firstString concatenated with secondString. You must print firstString  before secondString.

Sample Input 0

12
4.32
is the best place to learn and practice coding!

Sample Output 0

16
8.32
HackerRank is the best place to learn and practice coding!

Explanation 0

When we sum the integers 4 and 12, we get the integer 16.
When we sum the floating-point numbers 4.0 and 4.32, we get 8.32. When we concatenate HackerRank with, we get HackerRank is the best place to learn and practice coding!.

You will not pass this challenge if you attempt to assign the Sample Case values to your variables instead of following the instructions above.

Output

// Declare a variable named 'firstDecimal' and initialize with floating-point value 4.0.
    const firstDecimal = 4.0;
    
    // Declare a variable named 'firstString' and initialize with the string "HackerRank".
    const firstString = 'HackerRank ';
    
    // Write code that uses console.log to print the sum of the 'firstInteger' and 'secondInteger' (converted to a Number        type) on a new line.
    console.log(firstInteger+Number(secondInteger));
    
    // Write code that uses console.log to print the sum of 'firstDecimal' and 'secondDecimal' (converted to a Number            type) on a new line.
    console.log(firstDecimal+Number(secondDecimal));
    
    // Write code that uses console.log to print the concatenation of 'firstString' and 'secondString' on a new line. The        variable 'firstString' must be printed first.
    console.log(firstString + secondString);

If you’d like to see some more articles, be sure to read more blogs so you can keep up to date with the latest design tutorials and tricks.

Check out the complete series of 10 days of JavaScript HackerRank:

  1. Day 0: Hello, World! in Javascript| HackerRank Solutions

To contact me here’s my Instagram link: untied_blog

Read more

  1. how to get rich by coding? I make $100 every month from coding
  2. How To Create An App Without Coding| Build an App In 5 Minutes
  3. 11 Amazing ReactJS Projects Ideas For Beginners with Source Code
  4. How To Answer “Tell Me About Yourself”| Interview Questions.
  5. How To Answer “Strengths And Weaknesses” (Interview Questions)
  6. “Why Should We Hire You” 7+ Best Answers Examples

Leave a Comment