Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 8 pages
Exam (elaborations)

CPSC 1045 Midterm Exam 1- Solved

Document preview thumbnail
Preview 2 out of 8 pages

CPSC 1045 Midterm Exam 1- Solved

Content preview

CPSC 1045 Midterm Exam 1- Solved
Consider the following HTML paragraph
<p id="paragraph1">Here is a paragraph in English.</p>
Match each piece of the HTML element to its descriptor.

# opening tag
# attribute value
# text content
# attribute name
# closing tag

1.<p>
2.</p>
3.id
4."paragraph1"
5.Here is a paragraph in English. - ANSWER-1
4
5
3
2

Everything inside the
______
element is shown to the user inside the main browser window. Before this element we
will often see a
______
element that contains information about the page rather than information shown on the
page. This element usually contains a <title> tag. - ANSWER-body
head

For each scenario described select the appropriate input/output programming structure
you should use to complete the task.

# If a programming problem asks you to get the user input from a text field, you would
use...
# If a programming problem asks you to output some text to a textfield on the webpage,
you would use...
# If a programming problem asks you to output some value part way through your
program for debugging purposes, you would use...
# If a programming problem asks you to output some text to the HTML webpage (in say
a div or a paragraph), you would use..

1.let val = document.getElementById("someID").value;
2.document.getElementById("someID").innerHTML = "some text";

, 3.document.getElementById("someID").value = "some text";
4.console.log(value); - ANSWER-1
3
4
2

function doubleOrTriple( x ) {
if(typeof(x) !== "number"){
return NaN;
} if(50 <= x){
return x*2;
} else {
return x*3;
}
}

What value is returned by each of the following function calls?

1. doubleOrTriple(40)
2. doubleOrTriple(doubleOrTriple(40)) - ANSWER-1. 120
2. 240

function hypotenuse(a,b){
return Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
};
let a = 3;
let b = 4;
console.log(hypotenuse(a,b));

What is printed to the console? - ANSWER-5

function stringTooLong(str, length){
if(typeof(str) != "string" || isNaN(length)){
return false;
}else if(str.length() <= length){
return false;
}else{
return true;
}
}

Given the function above, in the first blank write a function call that will cause this
function to return true.
In the second blank write a function call that will cause this function to return false. -
ANSWER-stringTooLong("Hello", 1)
stringTooLong("Hello", 10)

Document information

Uploaded on
March 5, 2025
Number of pages
8
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$11.79

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
CLOUND
3.9
(128)
Sold
655
Followers
389
Items
12042
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions