- What is wrong with the following function? It is supposed to
find and return the value of the largest integer in an array of
integers. (There may be more than one problem with this function.
Describe all errors that you find. Also,
the errors are all logic errors - all of the statements are legal
JavaScript.)
function returnLargest(array)
{
var largest = array[0];
for (var i = 0; i< array.length; i++)
{
if (largest > array[i])
{
largest = i;
}
}
}
- How many times will the statement
doSomething();
be executed in the following loop?
for (var i = 0; i < 6; i = i + 2)
for (var j = 0; j <= 4; j++)
doSomething();
-
How many different numbers can be represented with 13 binary digits? How many different numbers can be represented with 3 hexadecimal digits?
- How is the decimal number 63 represented in
- What are the decimal representations of
- the binary number 1001101 ?
- the hexadecimal number B9 ?
Show some work for exercises 4 and 5 so that I can see how you
reached your answers.
-
The following is a binary representation of an ASCII encoded string.
Each eight-bit byte represents one character. (This is actually
UTF-8, a superset of ASCII. ASCII itself uses a 7-bit encoding.)
Decode the string. If you use any outside tools, reference them in
your answer.
0100001101010011001100010011000000110101