Question: (d) True or False: Is the following code valid JavaScript, considering standard web development practices and the proper use of JavaScript. Valid means there are

(d)

True or False: Is the following code valid JavaScript, considering standard web development practices and the proper use of JavaScript. Valid means there are no errors and will run properly while following proper programming techniques.

var subtract = function(x, y) { var z = x - y; return z; }; var result = subtract(4,3); 

Question: Why does this or does this not run correctly?

Note: Select 1 response for True/False and 1 response for the question for a total of 2 responses.

Group of answer choices

This is a properly written function expression and functions can be passed into variables in JavaScript

You can pass functions into variables as in "var result = subtract(4,3);" but you must use the "new" operator when creating the function

True

This is a properly written function expression, but an error occurs when you pass the function into a variable

False

There is a syntax error since there is a ";" semicolon after the function close bracket '}'

The function is written wrong, there should be a function name and no variable in front. You get another error when you try to pass the function into a variable during "var result = subtract(4,3);"

If you had defined the function like this "function subtract(x, y) { ... }" then it would be the correct way to declare the function and then "var result = subtract(4,3);" would also work.

None of the answers are correct

There is no compiler error, the code runs, but you do not get the correct output

(e)

Which jQuery function is used to run code AFTER the DOM is finished loading?

Note: Select all that apply.

Note: Determine which responses jQuery supports instead of only selecting the ones shown in class.

Note: Check the jQuery documentation and you can try to run some examples in Chrome as well.

Group of answer choices

 

Hello World

$(body).onload(function);
#(document).ready = function(){ };
   
$(document).loaded(function(){ });
function imReady(jQuery){ } $(document).ready(imReady); 
$(document).ready = function(){ };
$(document).ready(function(){ });
$(function() { });

None of the answers are correct

document.ready(function(){ });

(f)

What is the correct syntax for referring to an external script called "myScript.js" which is in the same directory as the HTML file using HTML5?

Note: Think of the proper programming techniques shown in class.

Group of answer choices

None of the answers are correct

(g)

Where can JavaScript be placed in an HTML5 document?

Note: Select one or more responses

Note: Remember the examples shown in class and proper programming techniques

Note: Technically JavaScript can be placed in many places but remember the proper places as shown in class.

Group of answer choices

Anywhere in the tag

At the beginning of the only

JavaScript can only be externally linked in the