Skip to content

Commit 4d2c0fd

Browse files
authored
Create Try_catch_finally.js
1 parent 0f7f955 commit 4d2c0fd

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
* Complete the reverseString function
27+
* Use console.log() to print to stdout.
28+
*/
29+
function reverseString(s) {
30+
31+
try{
32+
33+
console.log(s.split("").reverse().join(""))
34+
}
35+
catch(e){
36+
console.log(e.message); // Use .message, or you'll get more than expected.
37+
console.log(s);
38+
}
39+
40+
}

0 commit comments

Comments
 (0)