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 9 pages
Exam (elaborations)

JAVASCRIPT FINAL EXAM 2026.pdf 1. Document information

Document preview thumbnail
Preview 2 out of 9 pages

JAVASCRIPT FINAL EXAM 1. Document information

Content preview

JAVASCRIPT FINAL EXAM 2026/2027 QUESTIONS AND
SOLUTIONS RATED A+
✔✔Math.random() - ✔✔Generates a random floating point number between 0 & 1. To
convert this to a number range that we want - for example a random number between 1
& 10. First we multiply the result of Math.random() by 10 (the amount of potential
numbers from 1 to 10) - this will give us numbers that range from 0 to 9.99999. Because
Math.random() won't ever return the whole number 1 and to remove the decimal places,
we use Math.ceil()to round the result of Math.random()*10 up to the nearest whole
number. See more on the Math object.

✔✔What type of language is JavaScript? - ✔✔It is a scripting language.

✔✔What is a scripting language? - ✔✔A scripting language is a lightweight
programming language.

✔✔What would be the result of the following code?
<script>
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
</script> - ✔✔It will write what is between the <h1> and <p> tags to the browser screen
formatted accordingly to the respective HTML tags

✔✔What happens if you call the "document.write" function after the document has fully
loaded? - ✔✔The html document will be deleted and replaced by your new content.

✔✔The alert() function is not much used in JavaScript. What is it is useful for? - ✔✔It is
often quite handy for trying out code.

✔✔What will this code do?
<p id="demo"> JavaScript can change the content of an HTML element.</p>
<script>
function myFunction() {
x=document.getElementById("demo"); // Find the element
x.innerHTML="Hello JavaScript!"; // Change the content
}
</script> - ✔✔It will change the text between the <p> tags to the content in quotes after
x.innerHTML
Hello JavaScript!

✔✔What does this piece of code tell the computer to do ?
x=document.getElementById("demo") - ✔✔Find the Element ("demo");
document.getElementById("some id")
(The "Id" could be anything else.)

, ✔✔What does this piece of code tell the computer to do?
x.innerHTML="Hello JavaScript!"; - ✔✔Change the content of the x variable to Hello
JavaScript!

✔✔parseInt: If the first character cannot be converted to a number, what is returned? -
✔✔NaN

✔✔What does parseFloat do? - ✔✔It parses its argument, and returns a floating point
number. If it encounters a character other than a sign (+ or -), numeral (0-9), a decimal
point, or an exponent, it returns the value up to that point and ignores that character and
all succeeding characters. Leading and trailing spaces are allowed.

✔✔Math.random() - ✔✔This function returns a floating-point, pseudo-random number in
the range 0 to 1 — that is, from 0 (inclusive) up to but not including 1 (exclusive) —
which you can then scale to your desired range. The implementation selects the initial
seed to the random number generation algorithm; it cannot be chosen or reset by the
user.

✔✔What is the DOM? - ✔✔The DOM is a representation of a webpage that JavaScript
can use.

✔✔Object Prototype - ✔✔function Person(first, last, age, eyecolor) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eyecolor;

✔✔Which index is zero based? (The first element is 0, the second is 1, and so on.) -
✔✔Array

✔✔pop() - ✔✔Removes the last element of an array, and returns that element

✔✔push() - ✔✔Adds new elements to the end of an array, and returns the new length

✔✔shift() - ✔✔Removes the first element of an array, and returns that element

✔✔splice() - ✔✔adds/removes items to/from an array, and returns the removed item(s)

✔✔unshift() - ✔✔Adds new elements to the beginning of an array, and returns the new
length

✔✔children - ✔✔children property returns a collection of an element's child elements,
as an HTMLCollection object

Document information

Uploaded on
July 20, 2026
Number of pages
9
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$18.49

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.
BOARDWALK
3.5
(41)
Sold
284
Followers
11
Items
36005
Last sold
6 days 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