Skip to content

Commit 2a047c6

Browse files
authored
Merge pull request #4 from jangtaebin3/week4
[FEAT] 4주차 실습 내용
2 parents ade939c + d8dc425 commit 2a047c6

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed

Practice/week4/for.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
console.log('===== 초기 배열 데이터 =====');
2+
var arr = ["자바스크립트", "C언어", "파이썬"]
3+
4+
console.log(arr[0]);
5+
console.log(arr[1]);
6+
console.log(arr[2]);
7+
8+
console.log();
9+
console.log('===== 배열에 데이터 추가 =====');
10+
11+
arr.push('ASP.net');
12+
arr.push("c#.net");
13+
14+
console.log();
15+
console.log('===== 배열의 출력 =====');
16+
17+
console.log('배열의 길이 : ' + arr.length);
18+
for(var i = 0; i < arr.length; i++) {
19+
console.log(arr[i]);
20+
}
21+
22+

Practice/week4/if_else.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const readline = require('readline');
2+
3+
const rl = readline.createInterface ({
4+
input: process.stdin,
5+
output: process.stdout
6+
});
7+
8+
rl.question('정수를 입력하세요: ', function (num) {
9+
num = num % 2;
10+
if (num) {
11+
console.log('홀수입니다.');
12+
}
13+
else {
14+
console.log('짝수입니다.');
15+
}
16+
rl.close();
17+
});

Practice/week4/if_to_switch.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const readline = require('readline');
2+
3+
const rl = readline.createInterface ({
4+
input: process.stdin,
5+
output: process.stdout
6+
});
7+
8+
rl.question('점수를 입력하하세요. : ', function (score) {
9+
switch(Math.floor(score / 10)) {
10+
case 9:
11+
case 10:
12+
console.log('A');
13+
break;
14+
case 8:
15+
console.log('B');
16+
break;
17+
case 7:
18+
console.log('C');
19+
break;
20+
case 6:
21+
console.log('D');
22+
break;
23+
default:
24+
console.log('F');
25+
break;
26+
}
27+
rl.close();
28+
});

Practice/week4/switch_case.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const readline = require('readline');
2+
3+
const rl = readline.createInterface ({
4+
input: process.stdin,
5+
output: process.stdout
6+
});
7+
8+
rl.question('C 드라이브를 포맷하시겠습니까? (y / n)' , function(ch) {
9+
switch(ch)
10+
{
11+
case 'y':
12+
console.log('예, 드라이브를 포맷하겠습니다.');
13+
break;
14+
case 'n':
15+
console.log('아니요, 드라이브를 포맷하지 않겠습니다.');
16+
break;
17+
default:
18+
console.log('유효하지 않은 문자입니다.');
19+
break;
20+
}
21+
rl.close();
22+
});

Practice/week4/while.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const readline = require('readline');
2+
const rl = readline.createInterface({
3+
input: process.stdin,
4+
output: process.stdout
5+
});
6+
7+
rl.question('단수를 입력하세요. : ', function (dan) {
8+
var i = 1;
9+
while(i < 10)
10+
{
11+
console.log(dan * i);
12+
i++;
13+
}
14+
rl.close();
15+
});

0 commit comments

Comments
 (0)