임호준

0425 자바스크립트 실습

1 +<!DOCTYPE html>
2 +<html>
3 + <head>
4 + <meta charset="utf-8">
5 + <title>practice10</title>
6 + </head>
7 + <body>
8 + <input type="text" name="" value="" id="input1">
9 + <input type="button" name="" value="입력" onclick="call()">
10 +
11 + <div id = "div1">
12 +
13 + </div>
14 + <script type="text/javascript">
15 + function call(){
16 + // var birth = prompt("생년월일을 입력해주세요","6자리 입력");
17 +
18 + var birth = document.getElementById("input1").value;
19 + if(birth!=""){
20 + var temp= document.getElementById("div1");
21 + var a = birth.substr(0,2);
22 + var b = birth.substr(2,2);
23 + var c = birth.substr(4,2);
24 + //temp.innerHTML = birth.length;
25 + temp.innerHTML = "생일:19"+a+"년 "+b+"월 "+c+"일";
26 + }
27 +
28 +
29 +
30 + }
31 + </script>
32 + </body>
33 +</html>
1 +<!DOCTYPE html>
2 +<html>
3 + <head>
4 + <meta charset="utf-8">
5 + <title>practice10</title>
6 + </head>
7 + <body>
8 + 학점:
9 + <input type="text" name="" value="" id="input1">
10 + <input type="button" name="" value="입력" onclick="call()">
11 +
12 + <div id = "div1">
13 +
14 + </div>
15 + <script type="text/javascript">
16 + function call(){
17 +
18 +
19 + var score = document.getElementById("input1").value;
20 + if(score!=""){
21 + var temp= document.getElementById("div1");
22 + if(score>= 90){
23 + temp.innerHTML = "<h1>your grade is A</h1> ";
24 + }else if(score>=80 &&score<=89){
25 + temp.innerHTML = "<h1>your grade is B</h1> ";
26 + }else if(score>=70 &&score<=79){
27 + temp.innerHTML = "<h1>your grade is C</h1> ";
28 + }else{
29 + temp.innerHTML = "<h1>your grade is F</h1> ";
30 + }
31 +
32 +
33 +
34 + }
35 +
36 +
37 +
38 + }
39 + </script>
40 + </body>
41 +</html>
1 +var sum = 0;
2 +for(var i = 1; i <= 5; i++){
3 + sum+=i;
4 +}
5 +console.log(sum/5);
6 +
7 +var a = "1";
8 +var b = 2;
9 +
10 +console.log(a+b);
11 +
12 +var _a = 1;
13 +var _b = 2;
14 +
15 +console.log(_a+_b);
16 +
17 +console.log(parseFloat("23FF2"))