Top Posters
Since Sunday
New Topic  
ملك الموت ملك الموت
wrote...
Posts: 11
Rep: 0 0
2 years ago
JavaScript JQuery Questions


Question 1
Which jQuery is equivalent to the JavaScript statement

document.getElementById('company').focus();

?

Question 1 options:

$('company').focus();


$('.company').focus();


$('#company').focus();


$(company).focus();

Question 2
What will display in an alert box after running the following code?

y = "Goodbye";
z = "Hello" + 5 + y;
alert(z);

Question 2 options:

Hello 5 Goodbye


z


Hello5Goodbye


yz

Question 3
Which of the following is/are a valid first line(s) for an if statement?

Question 3 options:

if (x = correctAnswer) {


if (x == correctAnswer) {


if (x === correctAnswer) {


The first and second answers are both correct.


The second and third answers are both correct.


The first and third answers are both correct.

Question 4
What is incorrect about this function or function call?

function showPlanet(planetPosition, planetName) {
alert("The planet " + planetName + " is " + planetPosition + " planets from the sun.");
}

var planetName = "Earth";

showPlanet(planetName, 3);

 

Question 4 options:

planetName is a string, so it needs to have quote marks around it in the function call.


The arguments are in a different order in the function call and the first line of the function, so the wrong values are passed to the parameters in the function.


planetName should not have been defined as a separate variable. The name of the planet should have been in the function  call.


planetName is a string, so it needs to have quote marks around it in the first line of the function.

Question 5
What number should we put in
  • in the code below, if we want to display the planet Venus?

var planets = ["Mercury", "Venus", "Earth"];

alert(planets
  • );

Question 5 options:

0


2


3


1

Question 6
What symbol should we use before the number 5 in the code below, if we want the loop to run 5 times?

for (i = 0; i ? 5; i++) {
     text += "The number is " + i + "
";
}
document.write(text);

Question 6 options:

<=


>


<


=

Question 7
What symbol should we use before the number 5 in the code below, if we want the loop to run 5 times?

var text = "";
var i = 0;
while (i ? 5) {
     text += "
The number is " + i;
     i++;
}
document.write(text);

Question 7 options:

>


=


<


<=

Question 8
Which of the code samples below will display the value Earth, which was stored in a local storage in a browser, in a variable named planetName?

Question 8 options:

alert(localStorage.getItem("planetName"));


localStorage.setItem("planetName", "Earth");


sessionStorage.setItem("planetName", "Earth");


alert(sessionStorage.getItem("planetName"));

Question 9
Matching (10 points): jQuery Methods: For each item on the left, please choose the BEST match from the list on the right. There are extra items on the right that are not used. You may need to scroll down to see all 18 options on the right.

Question 9 options:

Used to connect to a button so a function will run when the button is clicked


Removes a class from a page


Can be used to jQuery to loop through the items in a list


Traverses the DOM to the item after the current one


Used in JavaScript when you want to create a loop with the variable to increment, the condition, and the amount to increment all in a single line of code


Hides one or more named sections on a page


Slides smoothly back and forth between show and hide states


Used to add new text and/or new HTML tags to a page


Applies CSS properties and values to a selection


Jumps quickly back and forth between show and hide states

1.   
append()

2.   
on()

3.   
addClass()

4.   
removeClass()

5.   
hide()

6.   
show()

7.   
for()

8.   
next()

9.   
toggle()

10.   
slideToggle()

11.   
toggleClass()

12.   
while()

13.   
alert()

14.   
fadeIn()

15.   
fadeOut()

16.   
css()

17.   
each()

Question 10
In the jQuery projects in this class, why do we put the .js files in a separate subfolder named scripts ?

Question 10 options:

There is no reason for it, but your instructor thought it would be good to get practice making additional folders.


The <script src...> tags expect the code to be a folder named scripts.


It helps to organize the code, just as we can use a styles or css folder to hold our CSS code.


The .js files will not run if they are in the same folder as the HTML files.

Question 11
We are using a minified version of jquery.js in this class. What does it mean when jQuery code is minified?

Question 11 options:

It means that shorter versions of functions were used whenever possible, to keep the code shorter.


It means that it contains only the basic jquery functions, that are used in the majority of projects. Additional functions are left out to save space.


It means that the carriage returns and extra spaces are removed from the code so the file is smaller.


It means that the jquery code is simplified for beginning users, so the file is smaller.

Question 12
What is the meaning of the dollar sign ( $ ) in this code, which we used at the top of every jQuery file?

$(document).ready(function() {

Question 12 options:

It is a variable representing the window object.


It is a variable representing the root element.


It is a variable representing the jQuery object .


It prevents the characters after it from being displayed on the screen.


It indicates that the characters after it are a string.

Question 13
The main code we use for jQuery has the word document in parentheses, as shown below. Why are there parentheses around the word document?

$(document).ready(function() {

Question 13 options:

It is a reserved word in JavaScript, so we need to tell JavaScript to replace its built-in meaning of document with this one.


We are passing the document object to the jQuery function.


It is a shortcut for needing to write
document.innerHTML.


It is a shortcut for needing to write document.getElementById().

Question 14  
The main jQuery function we have been using has the format below. At the end of it you can see a closing curly brace } followed by a closing parenthesis ). Why is the parenthesis after the curly brace, when we normally end a JavaScript function with a curly brace?

$(document).ready(function() {
     code....
});

Question 14 options:

The ending parenthesis is closing the jquery ($) function.


The ending parenthesis is closing the document (document) .


The ending parenthesis is closing the ready() method.


The ending parenthesis is closing the main function function() .

Question 15
Which jQuery code below would select all of the <h1> tags on the page?

Question 15 options:

$('#h1')


$('.h1')


$('h1')

Question 16
Which jQuery code below would select all of the tags on the page which have a class of my_class ?

Question 16 options:

$('.my_class')


$('#my_class')


$('my_class')

Question 17
Which jQuery code below would select the section of code on the page that has an ID of my_id ?

Question 17 options:

$('.my_id')


$('#my_id')


$('my_id')

Question 18
Which jQuery code below would select only the  h1 tags on the page that have a class of my_class ?

Question 18 options:

$('h1 my_class')


$('h1.my_class')


$('h1#my_class')

Question 19
When you download a jQuery plugin, most often you need the following file(s) to make it work:

Question 19 options:

The .js file for the plugin


The .js file and the .css file for the plugin.


The html file, the .js file and the .css file for the plugin.


The html file, the .js file, the .css file and the .php file for the plugin.

Question 20 (1 point)
How do we set options in a Plugin?

Question 20 options:

We use the setOptions() method


We use the .options property


We list all of our options and their values, with one curly brace at the beginning of the whole set of options and one curly brace at the end of the whole set of options.


We list all the options and their values, with a separate set of curly braces around each option.

Question 21
In several of the projects in the class, the keyword this is used. Here is an example:

$(this).next();

What is the meaning of this?

Question 21 options:

Refers to the method we are currently working in.


Refers to the object we are currently working with.


Refers to the property we are currently working with.


Refers to the event we are currently working with.

Question 22
In relation to jQuery, what is chaining?

Question 22 options:

Putting a series of objects one after another, in a row.


Putting a series of properties, one after another in a row.


Putting a series of methods, one after another, in a row.


Putting a series of events, one after another, in a row.

Question 23
True or False: In order to empty out a text box using a "Clear" button, all we need to do is to set its value to a space " ".

Question 23 options:
   True
   False
Question 24
Both of these expressions are equivalent, but the "on" method is considered more professional.

$("#myButton").click(function() {

$("#myButton").on("click", function() {


Question 24 options:
   True
   False
Question 25
Which of the following would correctly set the width of an image to 500 pixels using jQuery?

Question 25 options:

$("attr").img("width", "500");


$("img").attr("width", "500");


img.setAttribute("width",  "500");


setAttribute.img("width", "500");

Question 26
Which of the following will correctly read a value from a text box named specialBox, and assign it to a new variable named myVariable?

Question 26 options:

var myVariable = $("#specialBox").val();


var myVariable = $("#specialBox").val(myVariable);


var myVariable = $("myVariable#specialBox");


var myVariable = val("myVariable#specialBox");

Question 27
What is the correct code to set a value of Good Day! in an HTML tag with an ID of myTag?

Question 27 options:

$("#myTag").val("html", "Good Day!");


$("#myTag").text("html", "Good Day!");


$("#myTag").val("Good Day!");


$("#myTag").text("Good Day!");

Question 28
What is the purpose of the word return in the following code?

if (isNaN(myValue)) {
     alert("Enter a number in the box.");
     return;
}

Question 28 options:

To return the value that was entered in the box


To return the cursor to the box where the data was entered


To return the number that was entered in the box


To stop execution of the script at that point in the code

Question 29
Which function did we use to change the text entered in a text box to an integer, in both JavaScript and jQuery?

Question 29 options:

parseInt()


parsInt()


parseInteger()


parsInteger()

Question 30
Which code below would replace an image with an ID of myImage with a different image by the name of happy.jpg , using jQuery?

Question 30 options:

$('#myImage').src('attr', 'happy.jpg');


$('#myImage').attr('src', 'happy.jpg');


myImage.src ='happy.jpg';


myImage.src('attr', 'happy.jpg');

Question 31
In the hamburger menu code we used, we wrote code to hide and show which of the following elements?

Question 31 options:

.hamburger, .menu and .cross


.hamburger and .menu


.hamburger and .cross


.menu and .cross
Read 69 times
5 Replies
Replies
Answer accepted by topic starter
bio_manbio_man
wrote...
Educator
Top Poster
Posts: 33243
2 years ago Edited: 2 years ago, bio_man
Sign in or Sign up in seconds to unlock everything for free
This verified answer contains over 250 words.
1

Related Topics

ملك . Author
wrote...
2 years ago
Dear Mr. bio_man

Thank you so much. I really appreciate your help.

I hope you can complete the rest of the questions.

Thanks a lot
wrote...
Educator
2 years ago
Quote
Question 18
Which jQuery code below would select only the  h1 tags on the page that have a class of my_class ?

$('h1.my_class')

Quote
Question 19
When you download a jQuery plugin, most often you need the following file(s) to make it work:

The .js file and the .css file for the plugin.

Quote
Question 20 (1 point)
How do we set options in a Plugin?

We list all of our options and their values, with one curly brace at the beginning of the whole set of options and one curly brace at the end of the whole set of options.

Quote
Question 21
In several of the projects in the class, the keyword this is used. Here is an example:

$(this).next();

What is the meaning of this?

Refers to the method we are currently working in.

Quote
Question 22
In relation to jQuery, what is chaining?

Putting a series of methods, one after another, in a row.

Quote
Question 23
True or False: In order to empty out a text box using a "Clear" button, all we need to do is to set its value to a space " ".

   True

Quote
Question 24
Both of these expressions are equivalent, but the "on" method is considered more professional.

$("#myButton").click(function() {

$("#myButton").on("click", function() {

   True
   False

Quote
Question 25
Which of the following would correctly set the width of an image to 500 pixels using jQuery?

$("img").attr("width", "500");

Quote
Question 26
Which of the following will correctly read a value from a text box named specialBox, and assign it to a new variable named myVariable?

var myVariable = $("#specialBox").val();

I think...

Quote
Question 27
What is the correct code to set a value of Good Day! in an HTML tag with an ID of myTag?

$("#myTag").text("Good Day!");

Too many, you do the rest...
ملك . Author
wrote...
2 years ago
Dear Mr. bio_man

I did the rest, but I want to thank you because of your help I got an A.

 I really appreciate your help.

Words can't express how grateful I am to you.  Wink Face Slight Smile

Best regards,

wrote...
Educator
2 years ago
You're welcome. Good luck in that course
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1311 People Browsing
Related Images
  
 99
  
 399
  
 426
Your Opinion
Who's your favorite biologist?
Votes: 586

Previous poll results: Do you believe in global warming?