File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 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+ * A line of code that prints "Hello, World!" on a new line is provided in the editor.
27+ * Write a second line of code that prints the contents of 'parameterVariable' on a new line.
28+ *
29+ * Parameter:
30+ * parameterVariable - A string of text.
31+ **/
32+ function greeting ( parameterVariable ) {
33+ // This line prints 'Hello, World!' to the console:
34+ console . log ( 'Hello, World!' ) ;
35+
36+ // Write a line of code that prints parameterVariable to stdout using console.log:
37+ console . log ( parameterVariable ) ;
38+ }
39+
40+
41+ function main ( ) {
42+ const parameterVariable = readLine ( ) ;
43+
44+ greeting ( parameterVariable ) ;
45+ }
You can’t perform that action at this time.
0 commit comments