Circle the word TRUE or the word FALSE. If neither is circled, both are circled, or it impossible to tell which is circled, your answer is considered wrong.
count++;
is equivalent to count = count + 1;
function
keyword is used to
define a function.
Circle the letter of the best choice.
PrintGreeting();how many arguments does the function have?
[a.] 1
[b.] 0
[c.] 2
[d.] none of the above
[a.] tells the browser how to use the function.
[b.] gives information about the function to the person reading the code.
[c.] is necessary for the program to run.
[d.] all of the above.
var a = 3, b = 17 ; a = b % a ; b++ ; alert("a = " + a + ", b = " + b);
[a.] a = 3, b = 18
[b.] a = 2, b = 17
[c.] a = 3, b = 17
[d.] a = 2, b = 18
[e.] None of the above.
test = 1 ; if (test = 2) { alert("Beam down the landing party.\n") ; } else if (test == 1) { alert("Jim, he's dead.\n") ; } else if (test == 0) { alert("Scotty, four to beam up.\n") ; }
[a.] Beam down the landing party.
[b.] Jim, he's dead.
[c.] Scotty, four to beam up.
[d.] No output is produced
[a.] alert (x.toFixed(1));
[b.] alert (toFixed(x) = 1);
[c.] alert (x.toFixed(x));
[d.] alert (toFixed(1));
[a.] x--;
[b.] x - 1
[c.] x % 1
[d.] none of the above
ave = FindAverage(num1, num1);
[a.] 1
[b.] 0
[c.] 3
[d.] 2
PrintMessage("Hello there!");
[a.] 1
[b.] 0
[c.] 3
[d.] 2
[a.] function MyFunc()
[b.] function AddOne(num1)
[c.] function AddOne(num1, num2)
[d.] none of the above
[a.] 0
[b.] 10
[c.] 9
[d.] 1
[a.] \n
[b.] /n
[c.] enter
[d.] <br />
[a.] <hr />
[b.] <newline></newline>
[c.] <nl />
[d.] <br />
[a.] *
[b.] +
[c.] -
[d.] all of the above
[e.] none of the above
num
by 1?
[a.] num++
[b.] num = num + 1
[c.] num += 1
[d.] all of the above
[e.] none of the above
parseInt()
or parseFloat()
after a call to
prompt()
. When is it not necessary?
SumTwo
that returns the sum of
two numbers, where the numbers, num1
and num2
are passed to it.
Smallest
that takes three arguments, x
, y
and z
and returns the smallest of the three
arguments. You can assume x
, y
and z
are numbers.
AlertEven
that takes 1 argument,
n
, and alerts whether the value is even or not. The function
should not return anything. For example if n is 6, the output would be
"6 is even". If n is 7, the output would be "7 is not even".
Average
that takes three number
parameters n1, n2, and n3
and returns the value of the
average of the three.
SumN
that takes one parameter,
n
, and returns the sum of the integers from 1 to n.
You must use a for loop to find the sum.
FeetToInches
that takes
numFeet
as an argument and returns the number of inches
in that many feet. PrintBox
that will print a
rectangle made up of any character passed to it. Here is the function
header:
function PrintBox (rows, columns, ch)This call to PrintBox,
PrintBox(3, 10, "$");
$$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$
GPA range | Student Rating |
---|---|
3.50 - 4.0 | Dean's list |
2.0 - 3.49 | Satisfactory |
1.0 - 1.99 | Probation |
0.0 - 0.99 | Suspended |
numbers
, write a code segment that would
find the average of the array elements. You can assume that the array has already been
initialized to hold values.
numbers
, write a code segment that would
find the smallest element in the array. You can assume that the array has already been
initialized to hold values.
numbers
, write a code segment that would
find the largest element in the array. You can assume that the array has already been
initialized to hold values.
var i = 1; //this while loop displays the numbers 1-10 while (i <= 10) { alert("i is " + i); i--; }
Determine the output generated by the following code segments, assuming the surrounding program code (whatever it is) has no syntax errors.
alert ("JavaScript\nis\nfun.");
var a = 2, b = 3; b = b * a; b++; a += b; alert (a + " " + b);
var a = 5, b = 4; b += a; b++; a = a - b; document.write (a + " " + b);
var n = 1234; while (n > 0) { document.write(n + "<br />"); n = n / 10; n = Math.floor(n); } /* Hint: The Math.floor() function truncates a number downwards to the nearest integer. For example, the floor of 34.5 would be 34 */
var m; for (m = 1; m <= 5; m++) { switch (m) { case 1: document.write ("one"); break; case 2: document.write ("two"); break; case 3: document.write ("three"); break; default: document.write ("Default case"); } document.write ("<br />"); }
var x; for (x = 4; x >= 0; x--) { switch (x) { case 3: document.write ("tres"); break; case 2: document.write ("dos"); break; case 1: document.write ("uno"); break; default: document.write ("Default case"); } document.write ("<br />"); }
<head> <script type="text/javascript"> <!-- function X (m) { document.write("In function X: " + m + "<br />"); return (m + 2); } //--> </script> </head> <body> <script type="text/javascript"> <!-- var m; m = X(5); document.write("After the call to function X: " + m); //--> </script>
<head> <script type="text/javascript"> <!-- function Foo (num) { num++; document.write("In function Foo: " + num + "<br />"); return num; } //--> </script> </head> <body> <script type="text/javascript"> <!-- var num = 7; Foo(num); document.write("After the call to function Foo: " + num); //--> </script>