-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day 0 Data Types.js
66 lines (48 loc) · 1.59 KB
/
Day 0 Data Types.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', _ => {
inputString = inputString.trim().split('\n').map(string => {
return string.trim();
});
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
// Declare a variable i and initialize with integer value
var i = 4;
// Declare a variable d and initialize with decimal value
var d = 4.0;
// Declare a variable s and initialize with string value
var s = "HackerRank ";
// Read the integer from the stdin and save to your variable.
var int = readLine();
var num = parseInt(int)
// Read the decimal from the stdin and save to your variable.
var dec = parseFloat(readLine());
// Read the string from the stdin and save to your variable.
var string = readLine()
// Print the sum of both the integer variables on a new line.
var intSum = i + num;
console.log(intSum)
// Print the sum of the double variables on a new line.
var decSum = dec + d;
console.log(decSum)
// Concatenate and print the String variables on a new line. The variable 's' should be printed first.
var stringSum = s + string;
console.log(stringSum)
}
-
function main() {
const secondInteger = readLine();
const secondDecimal = readLine();
const secondString = readLine();
performOperation(secondInteger, secondDecimal, secondString);
}