Don’t say I never did nothin for ya.
You really should get use to using this tool. I cannot stress how invaluable it is. One of the great things about it is you can edit a page in real-time. By actually editing the content or disabling/enabling content you can see how it affects the structure of the page and how different elements on the page react when you change things around. Do this frequently, and take note of the HTML and CSS of pages you really admire the layout of. There is no shame in copy/pasting for now, but when pasting it make it your own – tweak it and modify to give yourself a better understanding of what HTML/CSS is capable of, and how the two rely on one another.
HTML: It is the content of your page, w. It is letters and number and nothing fancy at all. It is what you are reading, almost entirely text but also designations for breaking up the page into different distinct sections to be later altered with CSS.
CSS: Also called Cascading Style Sheets. CSS makes your HTML look attractive.
Think text-color, text-size, fonts, borders, background images or colors. Anything remotely aesthetics involved is very likely CSS acting on its HTML counterpart. In short, remove CSS from the equation and you get crappy looking 1993 looking websites.
Check out these resources:
What else? Well, we only want odd numbers, so how are we doing this? With an ‘if‘ statement of course. We do this because the loop is going to automatically increment the value of our variable but we only want some of those numbers, not all. So in each example, we ask that is the current value of our counter returns a remainder of 1 when divided by 2 than we want THAT number printed to our console.
%, if you are unfamiliar with it, is called a modolo. It returns the remainder of a division of two numbers. So for instance,
4 % 2 == 0 this is because 2 goes into 4 (2) times and there is nothing left after that, but
5 % 2 equals 1 this is because 2 goes into 5 (2) times but the remainder is 1
5-4 = 1 and so this is an excellent way to determine if a given number is either odd or even!
for (i = 0; i <= 100; i++)
for – initializes the loop (equivalent to ‘while’ in ruby)
i = 0 – same as in ruby initializing a variable to zero before the loop. It says, we have a variable called ‘i’ and it equals 0 right now.
i <= 100 – same as in ruby (while i <= 100) says, as long as the value is under this number continue with the loop party bruh.
i++ – same as in ruby where we have
i += 1 anytime you see a
++ in ruby after a variable it is a shorthand way of saying increment this number by 1. There are other kinds of incrementing and decrementing too though, by 5 or 10 or however much your heart desires my dear friend.
See that? Not so bad! Like I said previously, the logic of programming is something that you get to take with you whenever you pick up a different language. Of course, the benefit of different languages is what they are built for and what they are capable of performing, but the logic is all the same – stick to the principles that you already know and focus on the syntax and it will come to you a lot faster than you may think!
Until next time friends!