MOCK PRACTICAL PROGRAMS
Prepare the following program for MOCK Prctical
1) Take age input from user and classify as Child (0–12), Teen (13–19), Adult (20–59), or
Senior (60+).
2) Number is Even or Odd and Divisible by 5
3) Input a letter. Check if it’s a vowel (a, e, i, o, u) or consonant
4) Problem: Take a password and check:
● Less than 6 characters → Weak
● Contains numbers, upper & lower case → Strong
● Else → Medium
5) Take a number from 1 to 7 as input and display the corresponding day name using a
switch statement.
6) Simple Calculator -Build a calculator using a switch statement that performs one of the
following operations: +, –, ×, ÷
7) Input a string. Check if it reads the same forward and backward using a loop.
8) Number Stats Analyzer : Prompts the user 5 times using a for loop., Checks whether the
input is a valid number., Classifies each as positive, negative, or zero.,, Displays the count
of each.
9) Take a number N as input and print a number pyramid of N rows. For example, if N=5,
output:
1
12
123
1234
12345
10) Take a number N as input and print multiplication tables from 1 to N in a grid format.
For example, if N=3, output:
1 2 3
2 4 6
3 6 9
11) Count how many properties an object has and display keys and values.
12) Take an array of numbers and calculate the sum using for-of.
13. Write a function titleCase that converts a sentence to title case (the first letter of
each word capitalized).
14) Write a JavaScript program to pass a 'JavaScript function' as a
parameter.
15) Write JavaScript to find sum of even and odd numbers .
16) Write JavaScript to filter negative values from an array and display them.
17) Write JS to Create an array of product objects with fields: id, name, price, inStock. Use filter() to
return only available items. Use map() to create a list of product names with prices. Use arrow
functions throughout.
18) Create an input form that accepts two numbers and performs division. Handle the
case when the second number is 0 using try/catch/finally.
19) Create a form to validate an email address. If the input is not a valid email, throw
an error and display a message.
Expected Behavior:
● If the email does not contain @ and ., throw a custom error.
● Catch the error and show it in red.
20) Create a form where a user inputs their age. Throw and handle a custom error if
age is less than 18 or greater than 100.
Expected Behavior:
● Throw custom messages like "Too young" or "Too old".
● Show success if age is valid.