Chapter 4: JavaScript

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

What will the following HTML code do? <input type = "text" pattern = "[A-F]"> A) The text field will accept only character A B) The text field will accept only character F C) The text field will accept only character A, -, or F D) The text field will accept only character between A to F

D) The text field will accept only character between A to F

In JavaScript, a property of an object defines its ____. A) model B) make C) color D) characteristic

D) characteristic

In JavaScript, which of the following is the correct way to call a function called displayEquation? A) function displayEquation(); B) call displayEquation(); C) function = displayEquation(); D) displayEquation();

D) displayEquation();

How do you set all h1 elements with an id of "h" abckground color to red in JavaScript? A) document.h1.red; B) document.h1.style.red; C) document.getElementById("h").backgroundColor="red"; D) document.getElementById("h").style.backgroundColor="red";

D) document.getElementById("h").style.backgroundColor="red";

In JavaScript, how do you remove the decimal point of a number? A) Math.removedecimal(2.34); B) Math.nodecimal(2.34); C) Math.getInt(2.34); D) Math.floor(2.34);

D) Math.floor(2.34);

Which of the following JavaScript statements clear an input field value? A) document.GetElementById("userAnswer").value=" "; B) document.GetElementById("userAnswer").clear(); C) document.GetElementById("userAnswer").value.clear(); D) document.GetElementById("userAnswer").clear().value=" ";

A) document.GetElementById("userAnswer").value=" ";

In JavaScript, which of the following is the correct way to create a function called displayEquation? A) function displayEquation(); B) displayEquation() function; C) function = displayEquation(); D) displayEquation() = function;

A) function displayEquation();

JavaScript is ____. A) object-based B) variable-based C) method-based D) function-based

A) object-based

A property name in CSS often contains a hyphen, while in JavaScript that hyphen is often removed. A) true B) false

A) true

Variable names in JavaScript are case sensitive. A) true B) false

A) true

Which of the following is the correct way to store the random number in a variable called randNum? A) var randNum = Math.random(); B) Var randNum = random(); C) var randNum = random.Math(); D) var randNum = random(Math);

A) var randNum = Math.random();

In JavaScript, how do you separate words in a sentence into individual words and store them in an array? A) var words = sentence.split(" "); B) array words = sentence.split(" "); C) var[] words = sentence.split(" "); D) array[] words = sentence.split(" ");

A) var words = sentence.split(" ");

Programming languages use ___ to store values in computer memory so the values can be available to the programming instructions. A) variable B) special code C) HTML D) JavaScript

A) variable

How do you make a circle with CSS? A) Use circleShape property B) Use shapeCircle property C) Start with a square and set its diameter property D) Start with a square and set its borderRadius property

D) Start with a square and set its borderRadius property

Which of the following is a correct way for single line comments in JavaScript? A) <comment>This is a comment</comment> B) // This is a comment C) /comment D) <!-- This is a comment //-->

B) // This is a comment

To display the debug window in Firefox, you can ____. A) Ctr + U B) Ctr + Shift + K C) Ctr + J D) Ctr + J + S

B) Ctr + Shift + K

All JavaScript code has to be inside the <head> column A) True B) False

B) False

If you open an external JavaScript file in a text editor, ost likely the first line of code is <script>. A) True B) False

B) False

In JavaScript, which occurs when the user clicks in an HTML element? A) onmouseclick B) onclick C) onhover D) onhtml

B) onclick

JavaScript has a built-in function called _____ that will execute a function after a preset time duration. A) setDuration() B) setTimeout() C) setEvent() D) setTimer()

B) setTimeout()

Which of the following is a JavaScript variable naming rule? A) variable names are not case sensitive B) variable names should start with a letter, $, or underscore C) variable names should include both letters and numbers D) variable names can include spaces

B) variable names should start with a letter, $, or underscore

How do you refer to an external JavaScript file called language.js? A) <script href = "language.js"> </script> B) <script name = "language.js"> </script> C) <script src = "language.js"> </script> D) <script> language.js" </script>

C) <script src = "language.js"> </script>

Which of the following statements about JavaScript is correct? A) Java is short for JavaScript B) Java usually runs on a browser C) JavaScript usually runs on a browser D) JavaScript won't run without CSS

C) JavaScript usually runs on a browser

In JavaScript, how do you remove the decimal part of the number and retain only the whole number? A) Math.Round(x, 0); B) Math.round(x, 0); C) Math.floor(x); D) Math.floor(x, 0);

C) Math.floor(x);

JavaScript has a method called _____ which can call a function when an event is fired. A) addEvent B) callFunction C) addEventListener D) callFunctionListener

C) addEventListener

Which of the following JavaScript function will pop up a message box with words "It works!"? A) messagebox("It works!); B) msgbox("It works!); C) alert("It works!); D) alertbox("It works!);

C) alert("It works!);

When coding in JavaScript, you may have typos. The way to find the typo is called ____. A) typo finding B) bug finding C) debugging D) pre-executing

C) debugging

An object in JavaScript is a collection of ____. A) methods B) functions C) properties D) variables

C) properties

In JavaScript, how do you declare an array called digits? A) var digits = array; B) array digits; C) var digits = [ ]; D) array digits = [ ];

C) var digits = [ ];

How do you declare a variable in JavaScript? A) variable myVariableName; B) myVariableName variable; C) var myVariableName; D) var = myVariableName;

C) var myVariableName;

How many times will that following JavaScript code display "Hello world!"? for(var i = 0; i>5; i++){alert = "Hello world}; A) 0 B) 1 C) 4 D) 5

D) 5

In JavaScript, what is the value of x after var = 3; x+=4;? A) 1 B) 3 C) 4 D) 7

D) 7

Which of the following is the correct way to include JavaScript code in an HTML document? A) <javascript> //Insert Code here. </javascript> B) <type = "text/JavaSccript"> //Insert Code here. </type> C) <text/JavaScript> //Insert Code here. </text/JavaScript> D) <script> //Insert Code here. </script>

D) <script> //Insert Code here. </script>

The ____ is what the browsers see with the HTML document you created. It can be different from the HTML file you wrote. A) ECMA B) ECMAScript C) Java D) DOM

D) DOM

The official name for JavaScript is ______. A) JavaScript B) Vanilla JavaScript C) Java D) ECMAScript

D) ECMAScript

Which is the JavaScript syntax to change the content of the HTML element <p> with an id of "myParagraph"? A) document.getElementById("myParagraph")="New paragraph."; B) document.getElementById("p")="New paragraph."; C) document.getElementById("myParagraph").p="New paragraph."; D) document.getElementById("myParagraph").innerHTML="New paragraph.";

D) document.getElementById("myParagraph").innerHTML="New paragraph.";

A ____ is a group of JavaScript statements for the same purpose. A) group B) groupJS C) block D) function

D) function

Which of the following is the correct way to compare if the variable userAnswer is equal to 11? A) if userAnswer is 11 B) if userAnswer = 11 C) if userAnswer == 11 D) if (userAnswer == 11)

D) if (userAnswer == 11)


Ensembles d'études connexes

Microeconomics Chapter 6 Homework Quiz

View Set

Jason Dion Network+ N10 008 Missed Practice Test Questions, Ports and Protocols

View Set

HECO 1322 - Unit 3, Chapter 3-Digestion, Absorption, and Transport-Understanding Nutrition, Nutrition

View Set

French mercantilism and Colonial rivalry

View Set

ECON 1002: Chapter 9 (Business Cycles, Unemployment, and Inflation)

View Set

True - False Questions Biology A Final Exam

View Set

The Ancient Egyptian Pharaohs 10.25.15

View Set