
CIS 757790 JavaScript PROF. AUCIELLO
EXPLANATION:
This lessonquiz represents some 'breakthrough' thinking:
These quizzes demand interaction. The plan is to create the
equivalent of a classroom discusson on the Web. Added to
this is that you are graded for participating, and hopefully
you will glean information from others that will add to your
understanding and subsequently Mastery over the topics
discussed.
At the end of the lesson,  when you know that you understand
it  say "Mr. A. 
I got this lesson, thank you  and type your name.
Here is a copy of math8b.htm (GlassBox JavaScript Math Functions)
GLASS BOX Math and String Functions
THIS IS A GLASS BOX JAVASCRIPT EXERCISE BY PROF. AUCIELLO
Inputting Numbers
Q001: The script portion is stored in the HEAD section
of the HTML  Give me as deep an answer as you
can  How do you know that the javascript code
has to be in this section, and not the BODY?
(If you dont know, skip it, and come back to it later.)


Q002:
Translate (explain) this JS statement in English:
var mv = new String(this.document.forms[0].inputNum.value);


Q003:
Explain this:
alert("Math.sqrt(" + mv + ") yields " + Math.sqrt(mv));
Displays on screen:
Math.sqrt(123) yields 11.09053678912
Clue: 'alert' displays to screen. The sq rt of 'mv' is taken
and displayed. What do the '+' signs do?


Q004:
Given:
alert("The method 'Math.round.(Math.sqrt(" + mv + ")) yields
" + Math.round(Math.sqrt(mv)*100)/100 + " (rounded).");
that displays as:
The method 'Math.round.(Math.sqrt(123)') yields 11.09 (rounded)
Explain Math.round  how it works. Explain how it got rounded to 2 dec places.
Should include explanation of how mult and div are used to shift the decimal
position, and how that works with the round() function. (If you dont know,
skip it, and come back later.)


Q005:
Almost the same as Q004, EXPLAIN THE FOLLOWING
AND WHY IT IS DONE:
vara1= Math.round(100*Math.random())/100;
alert(vara1+ "= a randomlygenerated number between 0  1 [2 decimal places]");


Q006:
EXPLAIN EACH OF THE FOLLOWING LINES:
alert("The sine of PI = approximately 0!  Try it!");
alert("The sine of " + 3.141692 + " = " + Math.sin(3.141692) + " in radians.") ;
varc = Math.sqrt(mv);
alert("The sqrt of " +mv + " = " +varc + " The sqrt squared = " + Math.pow(varc,2));
alert("The sine of " + mv + " = " + Math.sin(mv));


Q007:
I HAD TO DO SOME PROGRAMMING TRICKS TO GET ADDITION TO WORK:
GO FIND IT, EXPLAIN IT, AND WHY I HAD TO DO IT THAT WAY:


Q008:
EXPLAIN THE 'length' function  how it works, and EXPLAIN
the substr function.
lmv = mv.length;
alert ("lmv = mv.length ");
alert ("The method 'lmv = mv.length' returns length of mv, stored in lmv.");
alert ("The length of " + mv + " = " + mv.length);
alert (mv + ".length" + " = " + lmv);
alert ("Position is counted from 0 position");
mmv = mv.substr(0,1);


Q009:
1
2
3 Inputting Numbers
4
15
16
Explain each line like this:
1. starts BODY, sets screen background color to yellow.
.
9 the form characteristics are: it accepts a field called
'inputNum' which is text, length of 8, initialized to null.


Q010:
I used "Glassbox" approach here contrasted with
"Blackbox"  Glassbox (GB) means opening up the process
so you can see what is happening inside.
Give an example from this lesson of GB.
Does it help you? Comments.
