Example 3 - Calculating powers

This example shows how one number can be raised to the power of another. Although there is a special instruction in JavaScript that does this, it is a rather neat demonstration of loops.

You are first asked for the number to be raised, and then for the power itself (which should be a positive whole number, please!). Then the calculation is performed and the answer displayed.