"JS10 Day 6: JavaScript Dates"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
9번째 줄: 9번째 줄:
----
----


<source lang='javascript'>
<syntaxhighlight lang='javascript'>
</source>
'use strict';
<source lang='javascript'>
 
</source>
process.stdin.resume();
<source lang='javascript'>
process.stdin.setEncoding('utf-8');
</source>
 
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++];
}
</syntaxhighlight>
<syntaxhighlight lang='javascript'>
// The days of the week are: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
function getDayName(dateString) {
    // Write your code here
    return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][new Date(dateString).getDay()]
}
</syntaxhighlight>
<syntaxhighlight lang='javascript'>
function main() {
    const d = +(readLine());
   
    for (let i = 0; i < d; i++) {
        const date = readLine();
       
        console.log(getDayName(date));
    }
}
</syntaxhighlight>

2020년 11월 2일 (월) 02:52 기준 최신판

개요[ | ]

JS10 Day 6: JavaScript Dates
해커랭크 10 Days of Javascript
# 문제 비고
6-7 Day e
18 JS10 Day 6: Bitwise Operators
19 JS10 Day 6: JavaScript Dates
20 JS10 Day 7: Regular Expressions I
21 JS10 Day 7: Regular Expressions II
22 JS10 Day 7: Regular Expressions III

'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++];
}
// The days of the week are: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
function getDayName(dateString) {
    // Write your code here
    return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][new Date(dateString).getDay()]
}
function main() {
    const d = +(readLine());
    
    for (let i = 0; i < d; i++) {
        const date = readLine();
        
        console.log(getDayName(date));
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}