Try Catch Finally Score
JavaScript
Easy
3 views
Problem Description
One integer x is given. In try block add 1, and if x
Input Format
One integer x.
Output Format
One integer score.
Constraints
x is a 32-bit integer.
Official Solution
const fs=require('fs');const s=fs.readFileSync(0,'utf8').trim();if(!s)process.exit(0);const x=Number(s);let score=0;try{score+=1;if(x<0)throw new Error('NEG');score+=2;}catch(e){score+=10;}finally{score+=100;}process.stdout.write(String(score));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!