HTML & CSS Layout Template

You can use the code below to set up an HTML document with a CSS layout including header, footer, sidebar, horizontal navigation menu, and single-column main content area. Here is …

Do..while Loops

Unlike the regular while loop, a do..while loop will run the block of code in the loop first and then check if the condition evaluates to true before it runs again (rather …

While loops in JavaScript

A while loop runs a set of instructions (block of code) while a test condition evaluates to true. A while loop can repeat a set of instructions over and over …

Switch statements

A switch statement is like an IF statement but is neater when working with many conditions. Use the break statement at the end of each case so that the code …

Nested If Statements

The sample code below shows how to use if statements inside other if statements (nested if statements). The video here explains all about nested if statements! <!DOCTYPE html> <html lang="en" …

If else statements

Often when using if statements, you will want to test more than just one condition. The sample code below explains how to do this. You can also watch the video …

If statements

An ‘if statement’ is used to test a condition. If the test condition evaluates to true (Eg. x is less than y), then the code inside the if statement will run. …

Arrays

Arrays are very useful in any programming language. When you use a simple variable, you can only store one value. For example age = 17 or name = “Harry”. But …

Functions with a parameter

The sample code shows how to make a function which uses a parameter.  A parameter is like a special variable which is used in a function to refer to a piece of data …

Events

This sample code snippet shows how to work with events (eg. onclick and onmouseover). It also shows how to use those annoying alert messages…but please, only use them for good! …

Strings

Quite a lot is going to be covered in the source code snippet below. You might want to watch the video which explains all about working with strings by clicking …