30 likes | 186 Views
04 Comments & Variables. Intro to Programming Using JavaScript. Exercises. Start with this: <html> <head> <title>JavaScript Homework Ch 4</title> <script language="JavaScript"> function Main() { /* Enter your JavaScript statements here */ } </script>
E N D
04 Comments & Variables Intro to ProgrammingUsing JavaScript
Exercises Start with this: <html> <head> <title>JavaScript Homework Ch 4</title> <script language="JavaScript"> function Main() { /* Enter your JavaScript statements here */ } </script> </head> <body> <input type="button" onclick="Main();" value="Click me!" id="hello1" /> </body> </html>
Exercises 1 Write some JavaScript code that prompts a user for the city and the state that he lives in (using 2 separate variables). Then create a 3rd variable that will contain something similar to “I hear it's beautiful in Williamsville, Illinois this time of year!” Then display the contents of that field in an alert box. Also, be sure to add comments, explaining what each variable is for. 2 Write a JavaScript program that asks for a name, street address, city, state, and zip and stores each in a separate variable. Also add a new variable, called newLine and assign it the string “<br />”. Then display the information directly on the web page in 3 lines, like it would appear on an envelope. The part of your program that writes to the web page should only use variables, and no string literals. Also add a multi-line comment that explains what the function Main is doing.