Stuckism Wales logo

WHAT IS CODE?

Return to Grumpy's Classroom

Open the link talk1 below and try inputting the following words in turn:
decimal
force
Force
What is the result?

talk1

When you open the talk1 code below you will see a function called clickHandler, which contains the following code:

if(question==="force")
{output.innerHTML="A force is a push or a pull";}
else{output.innerHTML = "I don't know about that"};

This code is saying: if the question input by you is the word "force", the computer answers that a force is a push or a pull.
Or else, it will answer that it doesn't know.

The code that does this is called JavaScript and it is contained between the signs "script" and "/script". JavaScript makes things happen. It does all the clever stuff!

The code sandwiched between the pointy brackets < and > is called HTML and it is the code which makes the webpages (like this one) which make up the world wide web.

talk1 Code

Instead of knowing only one thing, talk2 knows several! Try inputting the word "triangle" to it.

Look in the code of talk2 and you will see extra words and their meanings, in the clickHandler function.

talk2

talk2 Code