6.0 Quotes
To make Random Quotes, create forntend by HTML
Randomness
console.log(quotes[10]
We need function that can give us number 9 to 0.
1) To get the number 0~9
Math.random() * 10
2) To remove float numbers
Math.round (반올림)
Math.ceil (올림)
(1.01 -> 2, 1.0 -> 1.0, 1.1->2)
Math.floor (내림)
console.log(quotes[Math.floor(Math.random() * quotes.length)]);
(1) const todaysQuote = quotes[Math.floor(Math.random()*quotes.length)];
random number between zero to one
(2) const todaysQuote = quotes[Math.floor(Math.random()*quotes.length)];
multifly that for length of array
6.1 Background
const image = ["0.jpg", "1.jpg", "2.jpg" ...] -> array the images
*Paste something created with Javascript in the HTML
goal : to create string like - > <img src = "img/0.jpg">
const bgImage = document.createElement("img")
bcImage.src=`img/${chosenImage}`;
document.body.appendChild(bgImage);
-> appendChild is going to add an HTML to the body
-> append : is at the end / prepend : is on the top
'Java Script' 카테고리의 다른 글
To do list (2) (1) | 2024.08.29 |
---|---|
To do list (1) (0) | 2024.08.28 |
Clock (0) | 2024.08.26 |
Login Form (0) | 2024.08.23 |
Javascript on the browser (0) | 2024.08.22 |