[go: up one dir, main page]

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

Javascript Activity Part01 Withoutanswers

Uploaded by

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

Javascript Activity Part01 Withoutanswers

Uploaded by

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

Activity 01

Create a web page where JavaScript stores your name and favorite color in variables, then prints them
in the browser console using console.log().

Activity 02

Create a small webpage that:

1. Stores a student’s name and age in JavaScript variables.


2. Displays the values inside the webpage using document.write() or innerHTML.

Activity 03
Create a web page with the following:

1. A heading that says "Student Information".


2. Two empty paragraphs with id="name" and id="age".
3. A button labeled "Show Details".

When the button is clicked, JavaScript should use the innerHTML property to display:

 Name: YourName
 Age: YourAge

Activity 04

1. Defining a function:

function greetUser(name) { ... } → defines a function that takes one input


(name).

Inside, it uses console.log() to print a greeting message.

2. Calling a function:

greetUser("Chamari"); → runs the function with "Chamari" as input.

You can call it as many times as you want with different values.

3. Function with return value:

addNumbers(a, b) → takes two numbers, adds them, and returns the result.

Example: addNumbers(10, 20) returns 30.

4. Output: All results are displayed in the Console.


1
Activity 05

 Create a web page that uses JavaScript to:

 Store your name and favorite subject in two variables.


 Use document.write() to display them on the web page.

 Then, write another line using document.write() that shows a complete sentence like:

Hello, my name is Chamari and my favorite subject is IT.

Activity 06

 Create a web page using JavaScript where you:

 Write your name in bold.


 Write your favorite color in italic.
 Write your favorite hobby with an underline.

 Use document.write() with HTML formatting tags.

Activity 07

Create a JavaScript program that:

 Uses alert() to display a welcome message.


 Uses prompt() to ask the user for their name.
 Uses confirm() to ask if they like JavaScript.
 Displays the answers using document.write().

Activity 08
Create a web page that has:

 A button which shows an alert message when clicked (onclick).


 A paragraph that changes text when the mouse goes over it (onmouseover).
 The paragraph returns to the original text when the mouse moves out (onmouseout).

Activity 09
Write a program to display only the day of the week when the course begins.

Activity 10

Write a program to display only the time when the course begins.

You might also like