-
280920 #JavaScript ExercisesJavaScript 2020. 9. 28. 08:51
The <button> element should do something when someone clicks on it. Try to fix it!
<button onclick="alert('Hello')">Click me.</button>
The <div> element should turn red when someone moves the mouse over it.
<div onmouseover="this.style.backgroundColor='red'">myDIV.</div>
Use escape characters to alert We are "Vikings".
var txt = "We are \"Vikings\"";
Find the position of the character h in the string txt.
var txt = "abcdefghijklm"; var pos = txt.indexOf("h");
Convert the value of txt to upper case.
var txt = "Hello World"; txt = txt.toUpperCase();
Use the correct Array method to remove the last item of the fruits array.
var fruits = ["Banana", "Orange", "Apple"]; fruits.pop();
Use the correct Array method to add "Kiwi" to the fruits array.
var fruits = ["Banana", "Orange", "Apple"]; fruits.push("Kiwi");
Use the correct Array method to sort the fruits array alphabetically.
var fruits = ["Banana", "Orange", "Apple", "Kiwi"]; fruits.sort();
Use the correct Date method to extract the year (four digits) out of a date object.
var d = new Date(); year = d.getFullYear();
Use the correct Math method to round a number to the nearest integer.
var x = Math.round(5.3);
Create a loop that runs through each item in the fruits array.
var fruits = ["Apple", "Banana", "Orange"]; for (x of fruits) { console.log(x); }
Use the getElementsByTagName method to find the first <p> element, and change its text to "Hello".
<p id="demo"></p> <script> document.getElementsByTagName("p")[0].innerHTML = "Hello"; </script>
'JavaScript' 카테고리의 다른 글
051020 JavaScript 회원가입 (2) 2020.10.05 280920 Web SQL Database (0) 2020.09.28 240920 #003 BOM / DOM (0) 2020.09.24 230920 #002 상속 / 내장함수 및 객체 (1) 2020.09.23 220920 #001 JavaScript - (0) 2020.09.22