As always, spell check all content and identify your name and the current date in all files using comments. In html files you may use the html meta tag, e.g. <meta name="author" content="John Doe">
.
<p>
elements with id="q1"
, id="q2"
, and id="q3"
respectively.Operators | Meaning | Example and Return Value | Explanation of Example |
---|---|---|---|
== |
|||
=== |
|||
!= |
|||
!== |
|||
> |
|||
>= |
|||
< |
|||
<= |
|||
&& |
|||
|| |
|||
! |
Some characters have multiple uses. Identify each and provide an example.
Characters »» | (parentheses) | {curly braces} | [square brackets] | + symbol |
---|---|---|---|---|
usage 1 | [square brackets have only one usage, to identify an array index] | |||
usage 1 example | someArrayName[0] |
|||
usage 2 | [square brackets have only one usage, to identify an array index] | |||
usage 2 example | someArrayName[0] |
input
elements labeled Number Value 1
and String Value 2
id="value1"
and id="value2"
.type="number"
button
element with the text "Not Strict"
with id="testNotStrictButton"
button
element with the text "Strict"
with id="testStrictButton"
id="result"
if-then
construct and the second using a switch
construct...
Function #1: testNotStrict
testNotStrict
testNotStrict
declare two variables to get the values of the two input boxes. (Hint: Use the value
property to grab the value from an HTML input element.)type
an input element has been declared in the HTML. The type
attribute value changes the presentation of the input box to the user to limit the input to a number, date, valid email, so forth on the web page, but that's where the impact of the type
attribute stops. Regardless of the input's type
, the actual data in the input box is always passed to JavaScript as textual (string) data. id="value1"
as a number, it will need to be converted to a number in JavaScript. Use the parseInt()
function to convert the value of id="value1"
to a number in JavaScript.console.log
the values of your two variablestestNotStrict
compare the values from the two input boxes (now captured in your variables) using an if else
construct and an equality ==
comparison that is not strict.
id="result"
based on the comparison of the two values testNotStrict
from an event listener attached to the click
event of the id="testNotStrictButton"
button.Function #2: testStrict
testNotStrict
and paste it as a new function named testStrict
if else
structure and code the same functionality back into the testStrict
function using a switch
construct with cases for true
, false
, and default
. This time, test for strict equality ===
comparison and run case: true
or case: false
based on that strict comparison.testStrict
from an event listener attached to the click
event of id="testStrictButton"
An image of a potential solution is shown below. Note the console.log
values that are logging out the value of each input element when the Not Strict and Strict buttons are clicked.