JAVASCRIPT EXAM QUESTIONS AND
ANSWERS ALL CORRECT
What are comparison operators? - Answer-Comparison operators are used in logical
statements to determine equality or difference between variables or values
What are logical operators? - Answer-Logical operators are used to determine the logic
between variables or values.
What is a conditional operator? - Answer-assigns a value to a variable based on some
condition.
What are conditional statements - Answer-Conditional statements are used to perform
different actions based on different conditions
What if you don't want the script to execute immediately upon loading a page? -
Answer-then put it inside a function.
Where do you place functions and why? - Answer-in the head section, this way they are
all in one place, and they do not interfere with page content.
What do you need to do if there are no variables to pass to the function? - Answer-you
must still include the parenthesis () at the end of the function name.
When must the return statement be used? - Answer-when using a function that needs to
return a value
What is the purpose of the return statement? - Answer-to specify the value that is
returned from the function.
How do you insert Javascript into a web page? - Answer-with the script tag:<script
type="text/javascript">document.write("Hello World!");</script>
Where do you put javascripts? - Answer-in the head or body sections.
When do javascripts execute? - Answer-immediately. as the page loads into the
browser.
ANSWERS ALL CORRECT
What are comparison operators? - Answer-Comparison operators are used in logical
statements to determine equality or difference between variables or values
What are logical operators? - Answer-Logical operators are used to determine the logic
between variables or values.
What is a conditional operator? - Answer-assigns a value to a variable based on some
condition.
What are conditional statements - Answer-Conditional statements are used to perform
different actions based on different conditions
What if you don't want the script to execute immediately upon loading a page? -
Answer-then put it inside a function.
Where do you place functions and why? - Answer-in the head section, this way they are
all in one place, and they do not interfere with page content.
What do you need to do if there are no variables to pass to the function? - Answer-you
must still include the parenthesis () at the end of the function name.
When must the return statement be used? - Answer-when using a function that needs to
return a value
What is the purpose of the return statement? - Answer-to specify the value that is
returned from the function.
How do you insert Javascript into a web page? - Answer-with the script tag:<script
type="text/javascript">document.write("Hello World!");</script>
Where do you put javascripts? - Answer-in the head or body sections.
When do javascripts execute? - Answer-immediately. as the page loads into the
browser.