- What is the output for the following program: Put a box around your answer:
var a=2, b=7, c=9;
while ( a < 5 )
{
document.write(“Junk” + a + “<br>”);
while(c>5)
{
document.write(“in loop”+c+ “<br>”);
c=c-1;
}
if (a==3)
{
document.write(“is 3” + b + “<br>”);
b=b-2;
c=7;
}
a=a+1;
}
document.write(a+b+c);
- Give the output for the following code. Show the runtime stack.
function one(a,b)
{
var c=a-1;
document.write(“yes” + a + b + c + “<br>”);
a=b+1;
document.write(“no” + a + b + c + “<br>”);
return a;
}
function two(b,c)
{
a=7;
document.write(“first” + a + b + c + “<br>”);
c=one(b,a);
document.write(“last” + a + b + c + “<br>”);
}
a=3; b=4; c=9;
document.write(“one” + a + b + c + “<br>”);
b = one(c,a);
document.write(“two” + a + b + c + “<br>”);
two(a,c);
document.write(“three” + a + b + c + “<br>”);
Write Code: No Arrays: Name ________________________________
Write a JavaScript program that gets scores from the user until a score over 100 is entered.
For each score, tell if it is over or under 50. When you exit the loop, print the average of all
the even scores. Also print the highest odd score less than 80
- Array Competency: Name ________________________________________
Given you have a filled array of test scores. Write a function that is passed in this array
and prints every even test score that is more than 5 points above the average and more
than 5 points below the highest score in the array.