Skip to content

Commit 2a95eac

Browse files
authored
Create HelloWorld.js
1 parent d8aa1fb commit 2a95eac

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

HelloWorld.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

0 commit comments

Comments
 (0)