0% found this document useful (0 votes)
163 views7 pages

JS Assignment 2

The document contains instructions for a JavaScript programming assignment. It includes 12 tasks to complete like writing programs to greet users, perform calculations, validate passwords, and check number types. The tasks are to be completed individually and shared via a GitHub or Google Drive link for review.

Uploaded by

daljanmuhammad20
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)
163 views7 pages

JS Assignment 2

The document contains instructions for a JavaScript programming assignment. It includes 12 tasks to complete like writing programs to greet users, perform calculations, validate passwords, and check number types. The tasks are to be completed individually and shared via a GitHub or Google Drive link for review.

Uploaded by

daljanmuhammad20
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/ 7

Presidential Initiative for Artificial Intelligence and Computing (PIAIC)

https://www.piaic.org

JavaScript Programming Assignment 2

Note: Check Rules end of document

1. Write a program to take “city” name as input from user. If user enters
“Karachi”, welcome the user like this: “Welcome to city of lights”

2. Write a program to take input color of road traffic signal from the user
& show the message according to this table:

​https://www.piaic.org
3. Run this script, & check whether alert message would be displayed or
not. Record the outputs.
a. var a = 4;
if (++a === 5) {
alert("given condition for variable a is true");
}
b. var b = 82;
if (b++ === 83){
alert("given condition for variable b is true");
}
c. var c = 12;
if (c++ === 13){
alert("condition 1 is true");
}
if (c === 13){
alert("condition 2 is true");
}
if (++c < 14){
alert("condition 3 is true");
}
if(c === 14){
alert("condition 4 is true");
}
d. var materialCost = 20000;
var laborCost = 2000;
var totalCost = materialCost + laborCost;
if (totalCost === laborCost + materialCost){
alert("The cost equals");
}

​https://www.piaic.org
e. if (true){
alert("True");
}
if (false){
alert("False");
}
f. if("car" < "cat"){
alert("car is smaller than cat");
}

4. Write a program to take input the marks obtained in three subjects &
total marks. Compute & show the resulting percentage on your page.
Take percentage & compute grade as per following table:

Show the total marks, marks obtained, percentage, grade & remarks
like:

​https://www.piaic.org
5. Guess game​:
Store a secret number (ranging from 1 to 10) in a variable. Prompt
user to guess the secret number.
a. If user guesses the same number, show “Bingo! Correct
answer”.
b. If the guessed number +1 is the secret number, show “Close
enough to the correct answer”.

6. Write a program that checks whether the given input is an even


number or an odd number.

7. Write a program to create a calculator for +,-,*, / & % using if


statements. Take the following input:
a. First number
b. Second number
c. Operation (+, -, *, /, %)
Compute & show the calculated result to user.

​https://www.piaic.org
8. Write a program that takes input a number from user & state whether
the number is positive, negative or zero.

9. Write a program that takes a character (i.e. string of length 1) and


returns true if it is a vowel, false otherwise

10. Write a program that


a. Store correct password in a JS variable.
b. Asks the user to enter his/her password
c. Validate the two passwords:
i. Check if user has entered password. If not, then give the
message “ Please enter your password”
ii. Check if both passwords are the same. If they are the
same, show message “Correct! The password you
entered matches the original password”. Show “Incorrect
password” otherwise.

11. Write a program that take time as input from user in 24 hours clock
format like: 1900 = 7pm. Implement the following case using if, else &
else if statements

​https://www.piaic.org
​https://www.piaic.org
Rules for Assignment completion and submission

1) Each task should be in separate file


2) Files name should be the task name e.g task1, task2, task 3
a) task1.html
b) task1.js
3) You should upload your code on GitHub or google drive and share
link for code review
4) All files in assignment should be in one folder and folder name should
contains assignment number e.g assignment1_YourRollNo,
assignment2_YourRollNo
a) Create a folder
b) Add all tasks file in this assignment folder
c) Push code on github or upload folder on google drive
d) Share github url or drive url for code review

​https://www.piaic.org

You might also like