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:
- How to make money through coding? 9 Easy Ways To Make Money.
- 15+FREE Stuff For College Students Using Your College ID.
- how to get rich by coding? I make $100 every month from coding
Problem: Data Types in 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:
- Convert
secondInteger
to an integer (Number type), then sum it withfirstInteger
and print the result on a new line usingconsole.log
. - Convert
secondDecimal
to a floating-point number (Number type), then sum it withfirstDecimal
and print the result on a new line usingconsole.log
. - Print the concatenation of
firstString
andsecondString
on a new line usingconsole.log
. Note thatfirstString
must be printed first.
Input Format
Data Type | Parameter | Description |
---|---|---|
string | secondInteger | The string representation of an integer you must sum with firstInteger . |
string | secondDecimal | The string representation of a floating-point number you must sum with firstDecimal. |
string | secondString | A string of one or more space-separated words you must append to secondString. |
Output Format
Print the following three lines of output:
- On the first line, print the sum of
firstInteger
and the integer representation ofsecondInteger
. - On the second line, print the sum of
firstDecimal
and the floating-point representation ofsecondDecimal
. - On the third line, print
firstString
concatenated withsecondString
. You must printfirstString
beforesecondString
.
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:
To contact me here’s my Instagram link: untied_blog
Read more
- how to get rich by coding? I make $100 every month from coding
- How To Create An App Without Coding| Build an App In 5 Minutes
- 11 Amazing ReactJS Projects Ideas For Beginners with Source Code
- How To Answer “Tell Me About Yourself”| Interview Questions.
- How To Answer “Strengths And Weaknesses” (Interview Questions)
- “Why Should We Hire You” 7+ Best Answers Examples