JS10 Day 1: Let and Const

개요[ | ]

Day 1: Let and Const
해커랭크 10 Days of Javascript
# 문제 비고
0-1 Day e
1 JS10 Day 0: Hello, World!
2 JS10 Day 0: Data Types
3 JS10 Day 1: Arithmetic Operators
4 JS10 Day 1: Functions
5 JS10 Day 1: Let and Const

'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 main() {
    const PI = Math.PI;
    let r = readLine();
    console.log( PI*r*r );
    console.log( 2*PI*r );
    try {    
        // Attempt to redefine the value of constant variable PI
        PI = 0;
        // Attempt to print the value of PI
        console.log(PI);
    } catch(error) {
        console.error("You correctly declared 'PI' as a constant.");
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}