Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
46 views

Assignment 5

This document outlines 9 JavaScript assignments: 1. Display "Hello World" using alert, embedded JavaScript, and an external JavaScript file. Collect user input and store in a variable, then display it. 2. Find the area of a rectangle with width 4 and length 5. 3. Sort 3 numbers using conditional statements and display the result. 4. Iterate from 2 to 15 using a for loop, check if each number is prime, and display the results. 5. Accept 2 numbers from the user and display the larger. 6. Display a multiplication table for a number selected by the user. 7. Get and display the current date. 8. Display browser info, screen resolution,

Uploaded by

palashahuja123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Assignment 5

This document outlines 9 JavaScript assignments: 1. Display "Hello World" using alert, embedded JavaScript, and an external JavaScript file. Collect user input and store in a variable, then display it. 2. Find the area of a rectangle with width 4 and length 5. 3. Sort 3 numbers using conditional statements and display the result. 4. Iterate from 2 to 15 using a for loop, check if each number is prime, and display the results. 5. Accept 2 numbers from the user and display the larger. 6. Display a multiplication table for a number selected by the user. 7. Get and display the current date. 8. Display browser info, screen resolution,

Uploaded by

palashahuja123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 5(JavaScript Basic )

1. Simple JavaScript

A)

Alert Hello World using JavaScript

Write Hello World on webpage using embedded


JavaScript(using <script> and </script> in an HTML
document)
C) Write Hello World on webpage using external
javascript(write javascript code in myscript.js file and
import it into html file)
2. Collect information from the user and store in a variable for
later user.
B)

Create a basic page in html.


Using a prompt box, prompt the user to supply his or her
name.
Save the name in a variable.
Then, using a document.write() statement, use the
information stored in variables to display Hello
username! in big, bold letters, i.e. surrounded by <h1>
tags.
username should, of course, be what the user actually
typed into the prompt box.
Using the same variable, also display Hello username! in
an alert message on the same page.
3. Write a JavaScript program to find the area of a rectangle
where width=4 and length=5.
4. Write a JavaScript conditional statement to sort three numbers.
Display an alert box to show the result(Use if...else)
Sample numbers : 0, -1, 4
Output : 4, 0, -1

5. Write a JavaScript for loop that will iterate from 2 to 15. For

6.
7.

8.

9.

each iteration, it will check if the current number is prime or


non-prime, and display a message to the screen.
Sample Output :
"2 is prime"
"3 is prime"
"4 is non-prime"
------------------Write a JavaScript program that accept two integers and display
the larger(Use prompt box to take two numbers from user)
Write a JavaScript to display multiplication table of selected
number. The number should be selected using prompt box and
result should be displayed on the webpage.
Write a JavaScript program to get the current date(Hint: Use
inbuilt getDate() method)
Expected Output :
mm-dd-yyyy, mm/dd/yyyy or dd-mm-yyyy, dd/mm/yyyy
Display the following items in the page using only one or more
document.write() statements:
Information about the web browser that the user is
viewing this page with (hint: use the
navigator.appName property).
The height and width of the user's monitor, i.e.
the resolution(hint: use window.screen.availHeight and
window.screen.availWidth)
The date that the page was created or last modified (hint:
use the document.lastModified property).

You might also like