HTML, CSS, JavaScript are totally different languanges.
Just like, Swedish Finnsih or Norwegian
An HTML tag is made up of the element name followed by an optional list of attributes, all of which appears between angle brackets (< >). Nothing within the brackets is displayed in the browser.
A few tags do not have end tags because they are used to place standalone elements in the document or on the page. The image tag (<img>) is such a tag; it simply plops a graphic into the flow of the page. Other standalone tags include the linebreak (<br>), horizontal rule (<hr>).
See the Pen Untitled by Marcus Björke (@mbjorke) on CodePen.
or
Our goal for next time is to start and make a quiz game like this:
Here you can find the source code for the gameWhat is new code from last lesson?
Home assignment:
29.11.2021
In the previous lesson we mentioned class and how we used it to style the quizbox div. We also so a couple of examples where id was used on the quizbox game.
Correct answer is that the text would show as red because ID's are more specific than classes and take precedence over the id.
The function behind everything
or
The Wizard
The action that perform on the HTML elements
Methods:
The values of the HTML elements, that you can set or change
Propertis:
Remember to add semicolon ( ; ) at the end of the property to close the function
17.01.2022
Using an array literal is the easiest way to create a JavaScript Array.
Syntax:
const array_name = [item1, item2, ...];
To iterat an Array, we can use either for loop, forEach methods or manually add position index
But we have to know that an Array starts always from position 0
To get lenght of an Array, we have to use length method, by adding end of the array
const test_array = ['Iterate','this','Array'];
test_array.lenght // test_array length is 3
For Loop method
const test_array = ['Iterate','this','Array'];
for (let i = 0; i < test_array.length; i++) {
console.log(test_array[i]);
}
ForEach method
const test_array = ['Iterate','this','Array'];
test_array.forEach(function(value) {
console.log(value);
});
There is possible to manually get data without loop the array through
But should only use if you know that the value wont change and you will use same data over and ove again
Manually get data from the Array
const test_array = ['Iterate','this','Array'];
console.log(test_array[1]);
The if/else statement is a part of JavaScript's "Conditional" Statements, which are used to perform different actions based on different conditions.
In JavaScript we have the following conditional statements:
if statement
if (condition) {
// block of code to be executed
// if the condition is true
}
if / else statements
if (condition) {
// block of code to be executed
// if the condition is true
} else {
// block of code to be executed
// if the condition is false
}
if, else if and else statements
if (condition1) {
// block of code to be executed
// if condition1 is true
} else if (condition2) {
// block of code to be executed
// if the condition1 is false and
// condition2 is true
} else {
// block of code to be executed
// if the condition1 is false and
// condition2 is false
}
If statement for time
var time = new Date().getHours();
if (time < 10) {
greeting = "Good morning";
} else if (time < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
If statement to change font size
var x = document.getElementsByTagName("DIV")[0];
if (x.id === "myDIV") {
x.style.fontSize = "30px";
}
Home assignment:
Criteria:
Nice to have: