0% found this document useful (0 votes)
10 views6 pages

Assignment 2nd JavaScript Jawad Younas

javascript

Uploaded by

Sidra princess
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)
10 views6 pages

Assignment 2nd JavaScript Jawad Younas

javascript

Uploaded by

Sidra princess
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/ 6

Assignment 2nd JavaScript

(JavaScript)
1. Working with Arrays and Operators:
o You are developing a small e-commerce website where you need to store the
prices of five products in an array. Write a JavaScript program to:
 Calculate the total cost of all the products.
 Apply a 10% discount if the total cost exceeds $100.
 Output the discounted amount and the final price.
Program

Output

2. Conditional Statements and Loops:


o A company awards bonuses to employees based on their years of service:
 Less than 3 years: No bonus.
 3 to 5 years: 10% of their salary.
 More than 5 years: 20% of their salary.
Write a program that takes the salary and years of service as inputs,
calculates the bonus using a switch statement, and displays the bonus
amount.
Program
Output

s
3. Functions and Data Manipulation:
o Create a JavaScript function that takes an object as input representing a student's
details (e.g., name, roll number, and an array of marks in three subjects). The
function should:
 Calculate the average marks.
 Determine the grade using the following criteria:
 Average ≥ 80: Grade A.
 Average ≥ 60 but < 80: Grade B.
 Average < 60: Grade C.
 Output the student's name, roll number, average marks, and grade.
Program
Output
4.Working with Multi-Dimensional Arrays:
o You are tasked with creating a timetable for a school. The timetable is stored as a
2D array, where rows represent days and columns represent periods. Write a
program to:
 Populate the timetable with subject names (e.g., "Math", "Science").
 Display the timetable in a structured format using nested loops.
 Add a feature to search for a specific subject and display the day(s) and
period(s) where it is scheduled.
Program
Output

You might also like