My First Project!

Coding Samples

As a beginner programmer, I had my first web programing class this semester. I have learned HTML, CSS and JavaScript in this class, HTML is about basic structure that every html document follows. CSS is about how the webpage should look by using different colors, fonts, types and JavaScript allows you to control the behavior of the page. In this post I will add one of those examples of coding that we have learned in this semester.

We learned in HTML how to create a list in an html document. There are different types of lists you can create for ex: ordered list, unordered list, number list, nested list (list inside list). Here I have a code example of nested list where you can see sometimes data is organized into tree shape structure, which means it is connected to each other though link it is called a hierarchical database model. Nested list works like hierarchical database where you can see or understand all the contents inside the lists are indented, where they are listed in different parts and still connected. Each list has opening and closing tag, Ordered List has opening and closing tags which helps to understand that List(li) contents are nested inside the Ordered List.

Grocery List

<ul> <li>Dairy</li> <ol> <li>Milk</li> <li>Yogert</li> <li>Cream Cheese</li> </ol> <li>Vegetables</li> <ol> <li>Broccoli</li> <li>Carrots</li> </ol> </ul>

If statement is known as a control structure in JavaScript. If condition is true, we want some code to run and if the condition is false, we want to run other code. Boolean expression evaluates the result true or false. We can evaluate true or false by using an if statement. There are many operators we use in JavaScript. One of them is called Negation Operators (!), inside the if statement you can use this operator before a Boolean expression to change the result from true to false and false to true. We can you this to explain that something is not true or not false.

	var age = prompt("Enter your age");

	if(!age >= 18){
	alert("Sorry, you cannot vote")
}
		

This if statement says, "If age is not greater than or equal to 18, then you cannot vote" In this code above if we miss using negation operator,then it will completely change the meaning of the Boolean expression. we can get some result by using another approach.

	var age = prompt("Enter your age");

	if(age >= 18) == false){
	alert("I'm sorry, you canot vote");
}
		

This example you will get the same result, “If age is not greater than or equal to 18 then you cannot vote.” This is easier to see that the code is checking for the condition.