Introduction to JavaScript and Web Design
1. In
this code, several variables are used to store and work with numbers. The
variable price1 stores the value 5, and price2 stores the value 6. These
two values are added together, and the result is stored in the variable total.
Variables make it easier to store information and reuse it later in the
program.
The code
also uses the document object, which is a built-in JavaScript object that
represents the web page itself. Using
document.getElementById("demo"), the code is able to find the
paragraph element with the id demo and update its
content.
Overall,
the code works by adding price1 and price2 together and saving the result
in total. Then, the document object inserts the text “The total is: 11”
into the paragraph on the webpage so the result is displayed to the user.
2. In
Chapters 2–4 of Eloquent JavaScript, I learned about program structure,
variables, expressions, functions, and how control flow works in JavaScript, as
well as how JavaScript interacts with webpages through the DOM.
3. From testing the three image formats, PNG had the best image quality and handled transparency the best, but it also had a larger file size, which made it load a little slower. JPG loaded the fastest out of all three, but it does not support transparency. GIF had the lowest image quality, but it still worked well for simple images and animations. Overall, I believe that the best image format really depends on what the image is being used for.

Comments
Post a Comment