JS10 Day 3: Throw

개요[ | ]

JS10 Day 3: Throw
해커랭크 10 Days of Javascript
# 문제 비고
2-3 Day e
6 JS10 Day 2: Conditional Statements: If-Else
7 JS10 Day 2: Conditional Statements: Switch
8 JS10 Day 2: Loops
9 JS10 Day 3: Arrays
10 JS10 Day 3: Try, Catch, and Finally
11 JS10 Day 3: Throw

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});

function readLine() {
    return inputString[currentLine++];
}
function isPositive(a) {
    if( a == 0 ) return "Zero Error";
    if( a < 0 ) return "Negative Error";
    return "YES";
}
function main() {
    const n = +(readLine());
    
    for (let i = 0; i < n; i++) {
        const a = +(readLine());
      
        try {
            console.log(isPositive(a));
        } catch (e) {
            console.log(e.message);
        }
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}