Skip to content

Commit ee63ed2

Browse files
authored
Create DataTypes.js
1 parent 2a95eac commit ee63ed2

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

DataTypes.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+parseInt(secondInteger));
49+
50+
51+
// Write code that uses console.log to print the sum of 'firstDecimal' and 'secondDecimal' (converted to a Number type) on a new line.
52+
console.log(firstDecimal+parseFloat(secondDecimal));
53+
54+
// 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.
55+
console.log(firstString+secondString);
56+
}
57+
58+
59+
function main() {
60+
const secondInteger = readLine();
61+
const secondDecimal = readLine();
62+
const secondString = readLine();
63+
64+
performOperation(secondInteger, secondDecimal, secondString);
65+
}

0 commit comments

Comments
 (0)