Quiz 5 Solution

 

1. Write a JavaScript snippet that changes the background color of the browser window to blue and then displays a confirm box that tells the user that the background color is blue.

Solution

<script language=javascript>

function changeColor()
{
   document.bgColor ="#0000FF";
   confirm("The background color is now blue!");
}

</script>

OR

<script language=javascript>

function changeColor()
{
   document.bgColor ="blue";
   confirm("The background color is now blue!");
}

</script>

 

2. Write a function named Clinton that takes two arguments, named Pardon and Me, and returns 1E6 times the value in Pardon and adds to that Me.

Solution:

function Clinton(Pardon, Me)
{
   return Pardon * 1e6 + Me;
}