Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea554fe

Browse files
[Date 객체와 날짜] 과제 번역
- WIP- 충북대 실습 답안
1 parent8c198de commitea554fe

File tree

10 files changed

+42
-42
lines changed

10 files changed

+42
-42
lines changed

‎1-js/05-data-types/11-date/1-new-date/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The`new Date`constructor uses the local time zone. So the only important thing to remember is that months start from zero.
1+
`new Date`생성자는 로컬 시간대를 사용하기 때문에 특별히 지정해주지 않아도 됩니다. 주의할 점은 월이 0부터 시작한다는 것입니다.
22

3-
So February has number 1.
3+
따라서 2월은 숫자 1을 사용해 만듭니다.
44

55
```js run
66
let d=newDate(2012,1,20,3,12);

‎1-js/05-data-types/11-date/1-new-date/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ importance: 5
22

33
---
44

5-
#Create a date
5+
#날짜 생성하기
66

7-
Create a`Date` object for the date: Feb 20, 2012, 3:12am. The time zone is local.
7+
2012년 2월 20일, 오전 3시 12분을 나타내는`Date` 객체를 만들어보세요(시간대는 로컬).
88

9-
Show it using`alert`.
9+
그리고`alert` 함수를 이용해 생성한 객체를 출력하세요.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The method`date.getDay()`returns the number of the weekday, starting from sunday.
1+
`date.getDay()`메서드는 요일을 나타내는 숫자를 반환합니다(일요일부터 시작).
22

3-
Let's make an array of weekdays, so that we can get the proper day name by its number:
3+
요일이 담긴 배열을 만들고,`date.getDay()`를 호출해 반환받은 값을 인덱스로 사용하면 원하는 기능을 구현할 수 있습니다.
44

55
```js run demo
66
functiongetWeekDay(date) {
@@ -9,6 +9,6 @@ function getWeekDay(date) {
99
return days[date.getDay()];
1010
}
1111

12-
let date=newDate(2014,0,3);//3 Jan 2014
12+
let date=newDate(2014,0,3);//2014년 1월 3일
1313
alert(getWeekDay(date) );// FR
1414
```

‎1-js/05-data-types/11-date/2-get-week-day/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
#Show a weekday
5+
#요일 보여주기
66

7-
Write a function`getWeekDay(date)` to show the weekday in short format:'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'.
7+
날짜를 입력하면'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU' 형식으로 요일을 보여주는 함수`getWeekDay(date)`를 만들어보세요.
88

9-
For instance:
9+
예시:
1010

1111
```js no-beautify
12-
let date=newDate(2012,0,3);//3 Jan 2012
13-
alert(getWeekDay(date) );//should output"TU"
12+
let date=newDate(2012,0,3);//2012년 1월 3일
13+
alert(getWeekDay(date) );// "TU"가 출력되어야 합니다.
1414
```

‎1-js/05-data-types/11-date/3-weekday/_js.view/solution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function getLocalDay(date) {
22

33
letday=date.getDay();
44

5-
if(day==0){//weekday 0 (sunday) is 7 in european
5+
if(day==0){//일요일(숫자 0)은 유럽에선 7입니다.
66
day=7;
77
}
88

‎1-js/05-data-types/11-date/3-weekday/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
#European weekday
5+
#유럽 기준 달력
66

7-
European countries have days of week starting with Monday (number 1), then Tuesday (number 2) and till Sunday (number7).Write a function`getLocalDay(date)` that returns the "European" day of week for`date`.
7+
유럽국가의 달력은 월요일부터 시작합니다(월요일-1, 화요일-2, ... 일요일-7).'유럽' 기준 숫자를 반환해주는 함수`getLocalDay(date)`를 만들어보세요.
88

99
```js no-beautify
10-
let date=newDate(2012,0,3);//3 Jan 2012
11-
alert(getLocalDay(date) );//tuesday, should show 2
10+
let date=newDate(2012,0,3);//2019년 11월 5일
11+
alert(getLocalDay(date) );//금요일이므로, 5가 출력되어야 함
1212
```
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The idea is simple: to substract given number of days from`date`:
1+
구현 아이디어는 간단합니다.`date`에서 주어진 숫자를 빼면 됩니다.
22

33
```js
44
functiongetDateAgo(date,days) {
@@ -7,9 +7,9 @@ function getDateAgo(date, days) {
77
}
88
```
99

10-
...But the function should not change`date`. That's an important thing, because the outer code which gives us thedate does not expect it to change.
10+
그런데 주의사항에서`date`를 변경하지 말라고 했기 때문에 위와 같이 작성하면 오답이 됩니다. 외부 코드에서`date`를 사용하고 있는 경우,`date`를 수정하게 되면 원치 않는 일이 발생할 수 있습니다.
1111

12-
To implement it let's clone the date, like this:
12+
아래와 같이`date`를 복사하면`date`를 변경시키지 않고 원하는 기능을 구현할 수 있습니다.
1313

1414
```js run demo
1515
functiongetDateAgo(date,days) {
@@ -19,9 +19,9 @@ function getDateAgo(date, days) {
1919
returndateCopy.getDate();
2020
}
2121

22-
let date=newDate(2015,0,2);
22+
let date=newDate(2015,0,2);// 2015년 1월 2일
2323

24-
alert(getDateAgo(date,1) );// 1, (1 Jan 2015)
25-
alert(getDateAgo(date,2) );// 31, (31 Dec 2014)
26-
alert(getDateAgo(date,365) );// 2, (2 Jan 2014)
24+
alert(getDateAgo(date,1) );// 1, (2015년 1월 1일)
25+
alert(getDateAgo(date,2) );// 31, (2014년 12월 31일)
26+
alert(getDateAgo(date,365) );// 2, (2014년 1월 2일)
2727
```

‎1-js/05-data-types/11-date/4-get-date-ago/task.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ importance: 4
22

33
---
44

5-
#Which day of month was many days ago?
5+
#n일 전 '일' 출력하기
66

7-
Create a function`getDateAgo(date, days)` to return the day of month`days` ago from the`date`.
7+
`date`를 기준으로`days`일 전 '일'을 반환하는 함수`getDateAgo(date, days)`를 만들어보세요,
88

9-
For instance, if today is 20th, then`getDateAgo(new Date(), 1)` should be 19th and`getDateAgo(new Date(), 2)` should be 18th.
9+
오늘이 20일이라면`getDateAgo(new Date(), 1)`는 19를,`getDateAgo(new Date(), 2)`는 18을 반환해야 합니다.
1010

11-
Should work reliably for`days=365` or more:
11+
`days``365`일 때도 제대로 동작해야 합니다.
1212

1313
```js
14-
let date=newDate(2015,0,2);
14+
let date=newDate(2015,0,2);// 2015년 1월 2일
1515

16-
alert(getDateAgo(date,1) );// 1, (1 Jan 2015)
17-
alert(getDateAgo(date,2) );// 31, (31 Dec 2014)
18-
alert(getDateAgo(date,365) );// 2, (2 Jan 2014)
16+
alert(getDateAgo(date,1) );// 1, (2015년 1월 1일)
17+
alert(getDateAgo(date,2) );// 31, (2014년 12월 31일)
18+
alert(getDateAgo(date,365) );// 2, (2014년 1월 2일)
1919
```
2020

21-
P.S. The function should not modify the given`date`.
21+
주의: 함수는`date`를 변경하지 않아야 합니다.

‎1-js/05-data-types/11-date/5-last-day-of-month/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Let's create a date using the next month, but pass zero as the day:
1+
다음 달을 나타내는 객체를 만들고`day`에는`0`을 넘겨주면 됩니다.
22
```js run demo
33
functiongetLastDayOfMonth(year,month) {
44
let date=newDate(year, month+1,0);
@@ -10,4 +10,4 @@ alert( getLastDayOfMonth(2012, 1) ); // 29
1010
alert(getLastDayOfMonth(2013,1) );// 28
1111
```
1212

13-
Normally, dates start from 1, but technically we can pass any number, the date will autoadjust itself. So when we pass 0, then it means "one day before 1st day of the month", in other words: "the last day of the previous month".
13+
`new Date`의 세 번째 매개변수의 기본값은`1`입니다. 그런데 어떤 숫자를 넘겨줘도 자바스크립트는 이를 자동 조정해줍니다.`0`을 넘기면 '첫 번째 일의 1일 전'을 의미하게 됩니다. 이는 '이전 달의 마지막 일'과 동일합니다.

‎1-js/05-data-types/11-date/5-last-day-of-month/task.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
#Last day of month?
5+
#달의 마지막 일
66

7-
Write a function`getLastDayOfMonth(year, month)` that returns the last day of month. Sometimes it is 30th, 31st or even 28/29th for Feb.
7+
특정 달의 마지막 일을 반환하는 함수`getLastDayOfMonth(year, month)`를 작성해보세요. 반환 값은 30이나 31, 29(2월), 28(2월)이 될 겁니다.
88

9-
Parameters:
9+
매개변수:
1010

11-
-`year` --four-digits year, for instance 2012.
12-
-`month` --month, from 0 to 11.
11+
-`year` --숫자 4개로 구성된 연(예: 2012)
12+
-`month` --월(0부터 11)
1313

14-
For instance,`getLastDayOfMonth(2012, 1) = 29` (leap year, Feb).
14+
윤년인 2012년의 2월은 29가 반환되어야 합니다.`getLastDayOfMonth(2012, 1) = 29`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp