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
onlyJavaScript can only be externally linked in the
After but before the tag
Before
Anywhere in the
JavaScript can only be externally linked in the
None of the answers are correct
At the bottom fo the
(f)
Fill in the Blanks: In JavaScript, the third statement in a for loop is _____________ but often _______________ of the initial variable.
True/False: Therefore, the following code below will compile without errors and run correctly.
var cars = ["BMW", "Volvo", "Saab", "Ford"]; var i = 0; var len = cars.length; var text = ""; for (; i < len; ) { text += cars[i] + " "; i++; } Note: Select 1 response for each blank and 1 response for the last sentence whether it is true/false for a total of 3 responses.
Note: The best place to check whether JavaScript compiles and runs correctly is in the console on Chrome, which means you can write the code and run it to check.
Group of answer choices
None of the answers are correct
Creates a control variable
Required
Optional
Initializes the for loop
Sets the termination condition
Increments a counter
False
True
Recommended
(g)
A div element has the following style:
div { width: 656px; height: 500px; padding: 25px 14px 75px 10px; margin: 5px; border: 5px solid black; } Using the standard box model, what horizontal distance does the div occupy on the web page known as it's physical width?
Note: Enter the width below, remember to put your units. However, make sure your response has no spaces in it. For example: 1pt, 1px, 1em, etc.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
