JavaScript Quiz

Here is some code for a simple Quiz program written in JavaScript: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>Quiz</title>   <style> div#test{ border:#000 1px solid; padding:10px 40px 40px 40px; } </style> …

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 …

Variable scope

Now that you are using functions in JavaScript, it is really important to understand variable scope. JavaScript has two variable scopes: global and local. A global variable is a variable which is declared outside …

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 …

Functions

Functions allow you to write lines of code that can be used again and again in different parts of a program without actually having to write the lines of code …

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 …

Operators

If you have created your own variables and assigned them each a value (such as a string or integer), then you will already be familiar with the assignment operator which …