1
+ /**
2
+ *
3
+ * By Aman Shekhar
4
+ *
5
+ **/
6
+
7
+ 'use strict' ;
8
+
9
+ process . stdin . resume ( ) ;
10
+ process . stdin . setEncoding ( 'utf-8' ) ;
11
+
12
+ let inputString = '' ;
13
+ let currentLine = 0 ;
14
+
15
+ process . stdin . on ( 'data' , inputStdin => {
16
+ inputString += inputStdin ;
17
+ } ) ;
18
+
19
+ process . stdin . on ( 'end' , _ => {
20
+ inputString = inputString . trim ( ) . split ( '\n' ) . map ( string => {
21
+ return string . trim ( ) ;
22
+ } ) ;
23
+
24
+ main ( ) ;
25
+ } ) ;
26
+
27
+ function readLine ( ) {
28
+ return inputString [ currentLine ++ ] ;
29
+ }
30
+
31
+
32
+ /**
33
+ * The variables 'firstInteger', 'firstDecimal', and 'firstString' are declared for you -- do not modify them.
34
+ * Print three lines:
35
+ * 1. The sum of 'firstInteger' and the Number representation of 'secondInteger'.
36
+ * 2. The sum of 'firstDecimal' and the Number representation of 'secondDecimal'.
37
+ * 3. The concatenation of 'firstString' and 'secondString' ('firstString' must be first).
38
+ *
39
+ * Parameter(s):
40
+ * secondInteger - The string representation of an integer.
41
+ * secondDecimal - The string representation of a floating-point number.
42
+ * secondString - A string consisting of one or more space-separated words.
43
+ **/
44
+ function performOperation ( secondInteger , secondDecimal , secondString ) {
45
+ // Declare a variable named 'firstInteger' and initialize with integer value 4.
46
+ const firstInteger = 4 ;
47
+
48
+ // Declare a variable named 'firstDecimal' and initialize with floating-point value 4.0.
49
+ const firstDecimal = 4.0 ;
50
+
51
+ const firstString = 'HackerRank ' ;
52
+
53
+ console . log ( firstInteger + parseInt ( secondInteger ) )
54
+
55
+ console . log ( firstDecimal + parseFloat ( secondDecimal ) )
56
+
57
+ console . log ( firstString + secondString )
58
+ }
59
+
60
+
61
+
62
+ function main ( ) {
63
+ const secondInteger = readLine ( ) ;
64
+ const secondDecimal = readLine ( ) ;
65
+ const secondString = readLine ( ) ;
66
+
67
+ performOperation ( secondInteger , secondDecimal , secondString ) ;
68
+ }
0 commit comments