By the end of today, you will be able to:
with three sub-topics:
Here's a sample
<p style="color: gold"> Now is the winter of our discontent turned glorious summer by this <em>son</em> of York. </p>
Here's a sample
pre { color: chartreuse; }
// I have no idea what this function might do function foo(x, y) { var i; for( i = 0 ; i < x; i++ ) { if( g(i) ) { return i; } } }
QUESTION
parameter
argument
global variable
local variable
You are given two alternative definitions of a function:
function displayDate(){ var today = new Date(); document.querySelector("#date").innerHTML = today.toLocaleDateString(); }
function displayDate(dateStr, elemID){ var date = new Date(dateStr); document.querySelector(elemID).innerHTML = date.toLocaleDateString(); }
Which of the following statements is true? Explain your answer.
The two definitions are equivalent.
Definition 1 is better than Definition 2.
Definition 2 is better than Definition 1.
Which of the following function/method calls causes a side effect
instead of returning a value.
Math.random()
prompt("Enter your name:")
document.querySelector("img")
alert("Hello")
What is the output of executing the following code:
function isSquare(a, b, angle){ if (a == b && angle == 90) return true } alert(isSquare(10,11,90));
true
false
NaN
undefined
Modify the function amountToPay
from the last quiz question to
include a second parameter, stateTax
, so that it can calculate the amount
to pay depending on a buyer's state. You can that try to call the function a few
times such as below:
alert(amountToPay(100, 8.47)) // NY tax is 8.47% alert(amountToPay(50, 8.89)) // LA tax is 8.89%
As you know, when a list has an even number of items, the median is the mean
of the two middle values. Extend the findMedian
function
above to do the right thing depending on whether the given array
has an even or odd number of elements. The remainder operator %
is useful for finding if a number is odd or even.
We hope that after these activities you have a good understanding of:
Will be posted later, visit again after .