Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. JavaScript is a ______________ language. 2. In the following line, document i

ID: 3555649 • Letter: 1

Question

1. JavaScript is a ______________ language.

2. In the following line, document is a(n) ________ which resides in the computers memory and contains information used by the script. document.writeln("Hello World");

3. In the following line, writeln is a ________ which performs a task or action in the script. document.writeln("Hello World");

4. The line window.alert("Hello world") will display output in ________.

5. _______________ is a predefined dialog box for getting input from the user.

6. You use the _______________ keyword to declare a variable in JavaScript.

7. You use the /*...*/ syntax for a ______________.

8. You use the ______ operator to assign a value to a variable.

9. What is the value of the expression (3 + ( 5 + 4 ) * 7 + 4 ) / 5?

10. To convert a string to an integer, use the _______________ function.

11. Write a JavaScript program to do the following: 1. Ask the user for the ages of her three best friends. 2. Calculate the average age of the three friends. 3. Display the average age with appropriate labeling in the web page. For example, The average age of your three best friends is 24.7 years.

Explanation / Answer

1. Javascript is a prototype-based scripting language and which can be inserted into any HTML page, and it can be executed by all types of web browsers

2. Object

3. Method. ( Definition and Usage: The writeln() method is identical to the write() method, with the addition of writing a newline character after each statement.")

4. Alert Box. (The alert() method displays an alert box with a specified message and an OK button.)

5. Prompt Dialogue Box.

6. "var"

7. Multiline Comment (Similar to C-Programming /* ---------- */ is used for Multiline Comments)

8. "="

9. (3 + ( 5 + 4 ) * 7 + 4 ) / 5 = ( (3 + ( (9)*7 ) + 4) ) / 5 = (3+63+4)/5 = 14

10. parseInt()

11.

   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  
  <!DOCTYPE html>  <html>  <head>     <title>Average Age</title>     <script type="text/javascript">     function avgage(){         var i = prompt("Enter age of 1st friend");         var j = prompt("Enter age of 2nd friend");         var k = prompt("Enter age of 3rd friend");         document.writeln("The average age of your three best friends is "+((parseInt(i)+parseInt(j)+parseInt(k))/3)+" years");     }       </script>  </head>  <body>    </body>  </html>