URL : http://analytics.google.com
Math.random() * 100;
alert('안녕');
confirm('진짜?');
prompt('아이디?');
alert(Math.random()*100));
alert(1); alert(2);
for (let i=1; i<=10; i++)
alert(i);
<html>
<body>
<script>
alert('1');
alert('2');
alert('3');
</script>
</body>
</html>
<html>
<body>
<script>
document.write('1+1 = ');
document.write(1+1);
document.write('<br>');
const num = Math.random()*100;
document.write(Math.floor(num));
document.write('<br>');
document.write(num.toFixed(1));
document.write('<br>');
</script>
<input type = "button" value = "hello" onclick = "alert('안녕');">
</body>
</html>
<html>
<body>
<h1>Number</h1>
<script>
console.log(1);
console.log(1.2);
console.log('1 + 1 = ', 1+1);
console.log('5 - 3 = ', 5-3);
console.log('1 * 1 = ', 1*1);
console.log('4 / 4 = ', 4/4);
console.log('3 % 2 = ', 3%2);
console.log('Math.random : ', Math.random());
console.log('Math.Pi : ', Math.PI);
console.log('Math.floor(1.9) : ', Math.floor(1.9)); // 내림
console.log('Math.round(1.9) : ', Math.round(1.9)); // 반올림
console.log('toFixed : ', (Math.random()*100).toFixed(0));
//toFixed 소수점 자리 자르기
</script>
</body>
</html>
<h1>문자열(String)</h1>
<script>
console.log("hello world");
console.log(`hello
world`);
</script>
console.log('hello world'.length);
console.log('hell world'.replace('hell', 'hello'));
console.log('hello ' + 'world');
console.log('1'+'1');
<!DOCTYPE html>
<html>
<body>
<h1>Variable</h1>
<script>
var a = 1;
a = 2;
console.log(a);
let b = 1;
b = 2;
console.log(b);
</script>
</body>
</html>
document.querySelector('#container');
<input type = 'button' value = 'night mode' onclick = "document.querySelector('body').style.backgroundColor='black'">
<input type = 'button' value = 'day mode' onclick = "document.querySelector('body').style.backgroundColor='white'">
간단한 자바스크립트 문법을 가지고 여러가지를 실습해 볼 수 있었다.
아직까지는 어려웠던 점이나 해결하지 못한 것은 없으나,
여태까지 배운 것들을 복합적으로 사용할 수 있도록 복습이 필요하다고 생각되었다.