MTS JavaScript Review

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Variable x has a value of 5. Variable y has a value of 7.x !== 7 For this expressions, select True if the statement evaluates to true. Otherwise, select False.

True

Variable x has a value of 5. Variable y has a value of 7.x < 7 && y > 6For this expressions, select True if the statement evaluates to true. Otherwise, select False.

True

Variable x has a value of 5. Variable y has a value of 7.x == 6 || y == 6For this expressions, select True if the statement evaluates to true. Otherwise, select False.

True

totalScore is in the correct format according to standard naming conventions of JavaScript

True

When using a GET request with a form, the data length is restricted

YES

You work as a JavaScript developer for Adventure Works. You are writing a simple script that performs the following actions:✑ Declares and initializes an array✑ Fills the array with 10 random integers✑ Adds every other number starting with the first elementHow should you complete the code? To answer, select the appropriate code segments. You will have multiple (4) checks.

[ ] push j++ array[j]

You are designing a function that allows you to perform unit tests on other functions in a library. You will invoke each library function by using the eval JavaScript function. If an exception occurs when invoking a function, you want to display a message box with the following message:The function does not exist.How should you complete the code? To answer, select the appropriate code segment in the answer area.

catch try

What is the value of x?

"B"

Your instructor has asked you to write a program that uses simple rules to help determine if a person should take the train, drive their car, or ride a bike, depending on the conditions of the weather and the amount of gas in the car's tank.The program has the following requirements:✑ When the temperature is above 65 degrees and it is not raining, the person should be told to ride their bike.✑ When it is raining, the person should be told to drive their car.If their car has half a tank of gas or less, they should be told to take the train.How should you complete the code? To answer, select the appropriate code segments in the answer area.

&& <=

What is the value of each variable at line 07? To answer, match the appropriate value to the correct variable. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

0 = a 5 = d 10 = n 55 = c

You are creating a JavaScript program for an accounting system.You create the following code. Line numbers are included for reference only.You evaluate the code to ensure that it follows JavaScript best practices.Which line should you change?

03 03 var while = Date.now( );

A JavaScript array is initialized as follows:var array = [ 20, 40, 60, 80 ]You write the following code to manipulate the array:array.shift();array.pop();array.push(10);array.unshift(100);You need to determine the contents of the array.Which four elements does the array contain in sequence? To answer, move the appropriate elements from the list of elements to the answer area and arrange them in the correct order.Select all correct answers.

10 40 60 100

You are creating JavaScript code that manipulates dates. You want to initialize a Date object with the date January 1, 2017 by using the year, month, and date parameters.How should you complete the code? To answer, select the appropriate code segment, or multiple correct answers.

2017 0

You are creating a function that does safe division.The function has the following requirements:✑ The function receives two parameters for the numerator and denominator.✑ If the denominator is zero, the function must return false.✑ If the denominator is not zero, the function must return true.You write the following code. Line numbers are included for reference only.***SEE PICTURE AND DETERMINE IF THE FUNCTION WILL ALWAYS RETURN FALSE?***Select Yes if the statement is true. Otherwise, select No.

False

switch can be used as a variable name

False

~score can be used as a variable name.

False

How do you find the number with the highest value of x and y?

Math.max(x, y)

How do you round the number 7.25, to the nearest integer?

Math.round(7.25)

Form POST requests are cached.

NO

Form POST requests will always remain in the browser histroy.

NO

Only GET requests should be used when handling sensitive form data.

NO

This question requires that you evaluate the underlined text to determine if it is correct.You review the following JavaScript code:var x = 15;x %= 5;When this code executes, the value of x is 0.Review the underlined text. If it makes the statement correct, select "No change is needed". If the statement is incorrect, select the answer choice that makes the statement correct.

No change is needed

You analyze the following code fragment. Line numbers are included for reference only. Match the results with yes, no, absolutely no.

To call the multiply function on line 09 returns 200- no To call the multiply function on line 19 returns 100- absolutely no To call the multiply function on line 09 returns 100- yes

The characters // are used to mark a single line as a comment.

True

Variable x has a value of 5. Variable y has a value of 7.!(x == y)For this expressions, select True if the statement evaluates to true. Otherwise, select False.

True

You are creating a web page with a script. The script will insert the window's location inside the page's input element.How should you complete the code? To answer, drag the appropriate code segment to the correct locations. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.Select the two correct answers. window location document getElementById

document getElementById

What is the correct JavaScript syntax to change the content of the HTML element below?<p id="demo">This is a demonstration.</p>

document.getElementById("demo").innerHTML = "Hello World!";

You are writing a JavaScript program for Contoso Suites that will output HTML.You need to output each room type on a new line using the correct method.You create the following code for the function. Line numbers are included for reference only. You need to insert the correct code at Line 9. Which line should you use?

document.getElementById("para").innerHTML += rooms[i] + line.innerHTML;

You are designing a web page with a script that must dynamically change the content of a paragraph element to display the value returned by the function.randomQuote()You have created the following code. Line numbers are included for reference only.Which code segment should you use at line 08?

document.getElementById("tester").innerHTML = randomQuote();

You need to write a loop that will traverse the length of an array to find the value orange. If an array element value is null, the code should immediately go to the next element. When the value is found, the loop should exit.How should you complete the code? Select all correct answers to fill in the blanks.

for break while

How does a FOR loop start?

for (i = 0; i <= 5; i++)

You are writing an engineering application. You need to create a function that will round numbers to 3 or more decimal places.You need to create a function that receives the following two parameters:✑ The value parameter is the number to be formatted✑ The digits parameter is the number of digits to displayThe function must return the value with the number of digits specified.Which function should you use?

functions significance (value, digits){ return value.toFixed(digits);}

You are using JavaScript to create a function that calculates admission price.The function must meet the following requirements:✑ The function accepts the age of the customer as a parameter✑ A customer who is less than 5 years old gets in free✑ A customer who is 65 years old or older gets in free✑ A customer who is 5 years old to 17 years old, pays $10 USD✑ All other customers pay $20 USDHow should you complete the code? To answer, select the appropriate code segments in the answer area.

if (age >=5 && age < 18) if (age < 5 || age >= 65) {

How to write an IF statement for executing some code if "i" is NOT equal to 5?

if (i != 5)

How to write an IF statement in JavaScript?

if (i == 5)

How do you write a conditional statement that will "only"execute the contained code if variable x has a value 5 of type "number"?

if (x===5){...}

You are writing a JavaScript program for Blue Yonder Airlines. The program stores various information about the airline's flights.The program has initialized the following variables:*see image*You need to determine the data type of the code segment based on initialization and the assignment of the variables. Use the drop-down menus to select the answer choice that answers each question based on the information presented in the code segment.

line 01- string line 03- number line 04- boolean line 05- null

How to return the first value of this array?

myArr[0]; (correct answer)

What's the correct syntax for creating a Date object for January 10, 2020?

new Date(2020, 0, 10);

You are creating a dynamic HTML page by using JavaScript.Your page has an image of the sun. When the user's mouse pointer moves across the image of the sun, the image should change to the image of the moon.When the user's mouse pointer is no longer over the image should change back to the image of the sun.You need to write the code for the image swap.Which two events must you program for? (Choose two.)

onmouseout onmouseover

You are designing a web page that contains a blue button. When the button is pressed, it should call a function that displays the message "˜Welcome!'. When the cursor hovers over the button, the button should turn red. When the cursor leaves the button, the button should revert back to its original color of blue.You want to complete the markup using the appropriate HTML events.How should you complete the markup? To answer, select the appropriate event in the answer area.NOTE: select the two correct answers

onmouseover onclick

You are planning to use the Math object in a JavaScript application. You write the following code to evaluate various Math functions:*See image What are the final values for the three variables? To answer, select the appropriate values in the answer area.

round- 101 floor- 100 ceil- 101

You evaluate the following code: attached heretoYou need to determine the values of sampleStudent, sampleCourse.name, and sampleCourse.grade that are output by console.log().What are the final values for the three variables? To answer, select the correct answers. You should have three correct answers.

sampleStudent = HTML Student sampleCourse.name = JavaScript sampleCourse.grade = 100

You are creating a calendar application. You need to ensure that the code works correctly for all months of the year.How should you complete the code? To answer, select the appropriate options for each category of code in the picture.

switch (month) { break; break;

You are creating a web page that tests a user's ability to accurately type text. The validation should be case-insensitive.How should you complete the code? To answer, select multiple to fill in the blanks.Each function may be used once, more than once, or not at all.Select one for each blank.

value innerHTML value innerHTML

Primitive types are passed by

value (correct answer)

What is the correct way to write a JavaScript array?

var colors = ["red", "green", "blue"]

You are creating a JavaScript function that returns a date the specified number of months in the future of the current date.The function must meet the following requirements:Accept a number that represents the number of months to add or subtract from the current date.Return the current data adjusted by the number of months passed into the function.How should you complete the code? To answer, select all answers to complete the following code. function adjustMonth(value) { 1.________________ 2.____________________ 3. ___________________ return date;}

var date = new Date(); var month = date.getMonth(); date.setMonth(month + value);

You are creating a function named countdown. The function accepts a single parameter, start, and displays a countdown from that number down to zero in increments of one.How should you complete the code? To answer, select the appropriate code segments to complete the code.

var i = start; i>0; --i


Ensembles d'études connexes

'The Day the World Almost Came to an End'~Literature

View Set

Obesity Pathophysiology and Dyslipidemia

View Set

CH13: Strategic Leadership and Knowledge Management-m

View Set

Graph Transformations: Af(B(x-c))+D

View Set

unit 2 definitions and mult choice questions

View Set

ch 11, 12, 13 homework for final Macroeconomics(ACU Dr. Trent)

View Set

Chapter 8: Early Childhood Biosocial Development

View Set

2) Chapter 63 Care of Patients with Malnutrition and Obesity

View Set

Chapter 10 Earth and Water Study Guide

View Set