IU Bloomington Evaluation Services and Testing

Indiana University
Bloomington Evaluation Services and Testing

QuizSite  Students
Quizzes · Tests · Evaluations · Surveys
Activity: JavaScript
Student: dgerman (Adrian German)
Instructor: dgerman
Course: A348 Section: LECT
Question 1.
Consider the following JS code:
function f(x) {

  var y = 0;

  y = x;

}

y = 3;

f(6)

document.write("<h1>" + y + "</h1>");
You load the file in your web browser. What is it going to display?

y
6
3
<h1>y</h1>
nothing, an error will be reported


Question 2.
Consider the following JS code:
function f(x) {

  y = 0;

  y = x;

}

y = 3;

f(6)

document.write("<h1>" + y + "</h1>"); 
You load the file in your web browser. What is it going to display?

y
6
3
<h1>y</h1>
nothing, an error will be reported


Question 3.
Consider the following JS code:
function vector() {

  this.length = 0;

}

function addTo(vect, elem) {

  vect[vect.length + 1] = elem;

  vect.length += 1;

}

function s(t) {

  var v = 0;

  for (u in t) {

    v += t[u];

  }

  document.writeln(v); 

}

v = new vector();

addTo(v, 1);

addTo(v, 2);

addTo(v, 3);

s(v);
What will the browser display when you load this page in it?

3
6
7
9
length 1 2 3


Question 4.
Consider the following JS code:

function Globe() {

  this.x = 3;

  this.y = 3;

}

g = new Globe();

g["x"] += g.y; 

document.write(g.x);
What will the browser display when you load this page in it?

NaN
undefined
3
6
error:: JavaScript interpreter reports incorrect syntax


Question 5.
Consider the following JS code:
function a(x, y) {
  return x + y;
}
function b(x, y) {
  return x * y;
}
// a = b;
document.write(a(a(3, 4), b(3, 4))); 
What will the browser display when you load the page in it?

an error
no output
19
84
144
343


Question 6.
Consider the following JS code:
function a(x, y) {
  return x + y;
}
function b(x, y) {
  return x * y;
}
a = b;
document.write(a(a(3, 4), b(3, 4))); 
What will the browser display when you load the page in it?

an error
no output
19
84
144
343


Question 7.
Consider the following HTML enhanced code:
<form onSubmit="return false">

<input type="submit">

</form>
What will happen when you load it in your browser and click the button?

the form does not show and the button either
the button is there but nothing happens
error: the form has no method or action attributes
error: there is JavaScript error in the event handler


Click to submit your answers.   Help


This activity is available between these dates and times: 09.29.10:00-12.20.20:14
It can be submitted a total of 100 times.
If it is a scored activity, the highest non-zero score will be counted.


Screen: TAKE_QUIZ
Last updated: Thu Mar 8 13:40:07 2001
URL: https://www.indiana.edu/~best/cgi-bin/quizsite/students.pl
Comments: best@indiana.edu
Copyright 2000, BEST & The Trustees of Indiana University