Skip to content

Commit c1aab52

Browse files
authored
Create Day 0 : Data types
1 parent d661f8a commit c1aab52

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict';
2+
3+
process.stdin.resume();
4+
process.stdin.setEncoding('utf-8');
5+
6+
let inputString = '';
7+
let currentLine = 0;
8+
9+
process.stdin.on('data', inputStdin => {
10+
inputString += inputStdin;
11+
});
12+
13+
process.stdin.on('end', _ => {
14+
inputString = inputString.trim().split('\n').map(string => {
15+
return string.trim();
16+
});
17+
18+
main();
19+
});
20+
21+
function readLine() {
22+
return inputString[currentLine++];
23+
}
24+
25+
/**
26+
* The variables 'firstInteger', 'firstDecimal', and 'firstString' are declared for you -- do not modify them.
27+
* Print three lines:
28+
* 1. The sum of 'firstInteger' and the Number representation of 'secondInteger'.
29+
* 2. The sum of 'firstDecimal' and the Number representation of 'secondDecimal'.
30+
* 3. The concatenation of 'firstString' and 'secondString' ('firstString' must be first).
31+
*
32+
* Parameter(s):
33+
* secondInteger - The string representation of an integer.
34+
* secondDecimal - The string representation of a floating-point number.
35+
* secondString - A string consisting of one or more space-separated words.
36+
**/
37+
function performOperation(secondInteger, secondDecimal, secondString) {
38+
// Declare a variable named 'firstInteger' and initialize with integer value 4.
39+
const firstInteger = 4;
40+
41+
// Declare a variable named 'firstDecimal' and initialize with floating-point value 4.0.
42+
const firstDecimal = 4.0;
43+
44+
// Declare a variable named 'firstString' and initialize with the string "HackerRank".
45+
const firstString = 'HackerRank ';
46+
47+
// Write code that uses console.log to print the sum of the 'firstInteger' and 'secondInteger' (converted to a Number type) on a new line.
48+
console.log(firstInteger + Number(secondInteger));
49+
50+
// Write code that uses console.log to print the sum of 'firstDecimal' and 'secondDecimal' (converted to a Number type) on a new line.
51+
console.log(firstDecimal + Number(secondDecimal));
52+
53+
// 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.
54+
console.log(firstString.concat(secondString));
55+
}
56+

0 commit comments

Comments
 (0)