0% found this document useful (0 votes)
18 views2 pages

Web Tech Assignment 1

The document contains three examples of JavaScript code for web pages. The first example displays a welcome message with a line break, the second displays a paragraph alongside an image, and the third includes prompts to read numbers, calculate their product, and determine the largest number. Each example is structured within HTML and utilizes JavaScript for dynamic content manipulation.

Uploaded by

janeburden223
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Web Tech Assignment 1

The document contains three examples of JavaScript code for web pages. The first example displays a welcome message with a line break, the second displays a paragraph alongside an image, and the third includes prompts to read numbers, calculate their product, and determine the largest number. Each example is structured within HTML and utilizes JavaScript for dynamic content manipulation.

Uploaded by

janeburden223
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

write a web page with a Javascript to write, "Welcome to my very special page" with a line
break between "my” and "very".

<html>

<body>

<script>

document.write("Welcome to my" + "<br>" + "very special page");

</script>

</body>

</html>

2. write a web page with a javascript that display a paragraph with an image.

<html>

<body>

<p id="text">Welcome to my very special page!</p>

<img src="https://via.placeholder.com/150" id="image">

<script>

document.getElementById("image").style.width = "150px";

document.getElementById("image").style.height = "150px";

document.getElementById("image").style.float = "left";

document.getElementById("text").style.marginLeft = "165px";

</script>

</body>

</html>

3. Write Javascript code to do the following.


a. Read a number (using prompt) and display it using alert.
b. Read two numbers and display their product.
c. Read in two numbers and display the largest

// Read a number and display it using alert

var num1 = parseInt(prompt("Enter a number: "));

alert("The number you entered is: " + num1);


// Read two numbers and display their product

var num2 = parseInt(prompt("Enter the first number: "));

var num3 = parseInt(prompt("Enter the second number: "));

var product = num2 * num3;

alert("The product of " + num2 + " and " + num3 + " is: " + product);

// Read in two numbers and display the largest

var num4 = parseInt(prompt("Enter the first number: "));

var num5 = parseInt(prompt("Enter the second number: "));

var largest = (num4 > num5) ? num4 : num5;

alert("The largest number is: " + largest);

You might also like