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.Programming syntax is the set of rules that define the symbols and rules by which a particular language is written.
JavaScript syntax characters | description | provide an example |
---|---|---|
when do you use the semicolon ; | used to terminate a full statement | console.log("Hi World!"); |
when do you use { curly braces } | used to surround code blocks also used to create a custom object (but we are not that far in class yet so I wanted to provide this example) |
if (user === "Lisa") { const lisa = {
|
how do you write a one-line comment | ||
how do you write multi-line comment | ||
how do you declare variable | ||
how do you assign a textual value to a variable | ||
when do you use 'apostrophes' vs. "quotation marks" | ||
when do you use the backwards slash \ | ||
what is the most straight forward way of creating an array? |
In html file....
<body>
, after the table, add 6 paragraph tags with id="p1"
through id="p6"
respectively.script
tags just above the closing body
tag that reference a file named project2.js
in the same folder as the html file.Render your page in the browser and fix any errors using the html and css validators! In the browser, open the Console. (right-click your browser|Inspect|click Console tab)
In external js file named project2.js...
myName
with your full namepara1
and set it equal to document.getElementById("p1");
para1.textContent = myName;
Refresh your html page in the browser and fix any errors noted in the Console! You should see your name in paragraph 1!
In external js file...
n1
and n2
using any numeric values desired numberSum
to add the two numbers using their variable namesdocument.getElementById("p2").textContent = numberSum;
Refresh your html page in the browser and fix any errors noted in the Console! You should see the addition of your two numbers in paragraph 2!
In external js file...
numberMult
to multiply the two numbers using their variable names.document.getElementById("p3").textContent = numberMult;
Refresh your html page in the browser and fix any errors noted in the Console! You should see the multiplication of your two numbers in paragraph 3!
In external js file...
myNameAddNum
to add one of your numeric variables to the string variable document.getElementById("p4").textContent = myNameAddNum;
Refresh your html page in the browser and fix any errors noted in the Console! You should see the concatenation of your two numbers in paragraph 4!
In external js file...
myNameMultNum
to multiply one of your numeric variables to the string variable document.getElementById("p5").textContent = myNameMultNum;
Refresh your html page in the browser and fix any errors noted in the Console! You should see NaN (not a number) in paragraph 5!
In external js file...
ageCompare
to compare your age to the multiplication of your numeric variables (hint, use <, <=, >, or >= to do a comparison. The comparison will evaluate true or false).document.getElementById("p6").textContent = ageCompare;
Refresh your html page in the browser and fix any errors noted in the Console!
In external js file...
n1
and n2
values.Refresh your web page to observe the changes. Do this as often as you desire. Have fun!
id="p7"
.id="p8"
.textContent
and innerHTML
properties and why was it more appropriate to use textContent
for this exercise? id="p9"
.id="p10"
.id="p11"
.id="p12"
.