Technodynamic
04-15-2006, 04:55 PM
I've used javascript for awhile, all self taught, but now I am learning it for real so I can get certified. I have a few script questions and for anyone with some experience, they should be fairly easy. I really appreciate the help.
Also, please provide how you got the answer so I can learn. :o :)
What is the value of "total" after execution of the below code?
j = 0;
total = 0;
do
{
j++;
total = total ^ j;
}
while (j < 2);
Referring to the below code, if checkbox "s" is checked, and parameter "fld" is equal to "q," what does function calc return?
function calc(form,fld) {
var d = 0;
if(fld == "r") {
if(form.s.checked) {
d=Math.sqrt(form.r.value); }
else { d=form.r.value/2; }
} else {
if (form.s.checked) {
d = form.e.value * form.e.value;
} else { d = form.e.value * 2; }
}
return d;
}
Referring to the below code, what is the value of "ch2" after execution?
var ch1 = 'b';
var ch2;
switch(ch1) {
case 'a':
ch2 = '1';
case 'b':
ch2 = '2';
case 'c':
ch2 = '3';
break;
default:
ch2 = '4';
}
Also, please provide how you got the answer so I can learn. :o :)
What is the value of "total" after execution of the below code?
j = 0;
total = 0;
do
{
j++;
total = total ^ j;
}
while (j < 2);
Referring to the below code, if checkbox "s" is checked, and parameter "fld" is equal to "q," what does function calc return?
function calc(form,fld) {
var d = 0;
if(fld == "r") {
if(form.s.checked) {
d=Math.sqrt(form.r.value); }
else { d=form.r.value/2; }
} else {
if (form.s.checked) {
d = form.e.value * form.e.value;
} else { d = form.e.value * 2; }
}
return d;
}
Referring to the below code, what is the value of "ch2" after execution?
var ch1 = 'b';
var ch2;
switch(ch1) {
case 'a':
ch2 = '1';
case 'b':
ch2 = '2';
case 'c':
ch2 = '3';
break;
default:
ch2 = '4';
}