• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

EXERCISES

1:Copy the following file and execute it in your browser. What's wrong with it and why? Can you fix it?
<html><head><title>link</title>
<script language="JavaScript">
function addem(){
  var n = 2;
  var y = 3;
  document.write( n + y , "<br>");
}
</script>
</head>
<body bgcolor=red>
<a href="javascript:addem()">Click here</a>
<h2>Hello</h2>
</body>
</html>

2:Write a function that will calculate and return the amount that should be paid as a tip for a resturant bill. The tip will be 20 percent of the total bill.
3:Create a function called changeColor() that will be called when the user presses one of two buttons. The first button will contain the text “Press here for a yellow background”. The second button will contain the text “Press here for a light green background”. The function will take one parameter, a color. Its function is to change the background color of the current document.
4:What is recursion? What is the danger of using it?
5:Write a function that returns the total cost of any number of buckets of paint. Ask the user how many buckets he is going to buy and for the cost of one bucket. Ask him the color of the paint. Calculate and return what he owes. Change the color of the font to the color of the paint.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint