Although you really just need syntax at your level, I am still going to explain the uses of these control commands. If you have suggestions, they are welcome.
First, to execute commands based upon a condition, you use if with the option of also using else to tell what to do if the condition isn't met. In other words do this if something is true or that if it is false.

<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript">
function setColor()
  {
  var sex=prompt("Are you a boy or a girl?","boy");
   if (sex=="boy")
    {
    document.body.style.backgroundColor="blue"
    }
  else
    {
    document.body.style.backgroundColor="pink"
    }
  }
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="button" ONCLICK="setColor()" VALUE="Click">
</BODY>
</HTML>

Code

Notice that "=" is used to assign values to variables but "==" is used for comparisons. Next we need to know how to specify more than one condition in our if command. Suppose instead of a color for boy and a color for girl, we change the background color if the user answers boy or girl. OR is "||", AND is "&&" and NOT is "!=" (we'll use the others as the need arises).

<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript">
function setColor()
  {
  var sex=prompt("Are you a boy or a girl?","boy");
  if (sex=="boy" || sex=="girl")
    {
    document.body.style.backgroundColor="blue"
    }
  }
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="button" ONCLICK="setColor()" VALUE="Click">
</BODY>
</HTML>

Code

The last thing we'll look at is the two ways of repeating instructions. The for command and the while command. If you know how many times you want to do something use for otherwise use while as in this example:

<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript">
function setColor()
  {
  var bgColor=prompt("What color do you want the background to be?\n(Enter \"none\" to exit.)" ,"none");
  while (bgColor!="none")
    {
    document.body.style.backgroundColor=bgColor;
    bgColor=prompt("What color do you want the background to be","none")
    }
  document.write("<CENTER>Thanks for playing!</CENTER>")
  }
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="button" ONCLICK="setColor()" VALUE="Start">
</BODY>
</HTML>

Code

Notice the "\n"? That is the escape code for a line break. And here is a short for example:

<HTML>
<BODY>
<SCRIPT TYPE="text/javascript">
  for (color=0; color <= 1000; color=color + 10)
    {
    document.body.style.backgroundColor=color;
    alert("This is color " + color)
    }
</SCRIPT>
</BODY>
</HTML>

Code

Now the last of the control commands is switch. It is for choosing between several choices rather than just the two that if/else affords. You choose from amoung several "cases" and if any other value is specified, it will execute the "default" case. Notice that each case is ended with a break except the last one.
Here is how it looks:

<HTML>
<HEAD>
<SCRIPT TYPE="text/javascript">
  function choosePhrase()
  {
  var myChoice=parseInt(Math.random()*4);
    switch (myChoice)
    {
    case 1:
      myPhrase="You are crazy!";
      break
    case 2:
      myPhrase="You are clever!";
      break
    case 3:
      myPhrase="You are pretty!";
      break
    default:
      myPhrase="Go away!"
    }
  alert(myPhrase)
  }
</SCRIPT>
</HEAD>
<BODY>
</BODY>
<INPUT TYPE="button" ONCLICK="choosePhrase()" VALUE="Click">
</HTML>

Code

Now you are ready for your first real programming assignment:
Write a program which asks the user to guess a number between 1 and 100. Use the math function random to choose the number. And before the game begins ask the user how many guesses he wants. After each guess tell the user whether the number is higher or lower than his guess. Keep track of the number of guesses and report that at the end of the game. The game should end when 1) the user guesses the number or 2) the number of guesses specified by the user has been reached.

Enhancement Ideas:
1) Dress up the page with formating.
2) Make a scale for guesses, ranking the user's score.
Here is my solution but only look at the source code once you are done.

Demo 1