0% found this document useful (0 votes)
10 views

Prelim CSS

Model exam paper of subject CSS

Uploaded by

Suyash Patil
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)
10 views

Prelim CSS

Model exam paper of subject CSS

Uploaded by

Suyash Patil
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/ 11

1]

Write a simple calculator program using switch case in JS.

function calculator(num1, num2, operator) {

let result;

switch (operator) {

case '+':

result = num1 + num2;

break;

case '-':

result = num1 - num2;

break;

case '*':

result = num1 * num2;

break;

case '/':

if (num2 !== 0) {

result = num1 / num2;

} else {

return "Error: Division by zero is not allowed.";

break;

default:

return "Error: Invalid operator. Please use +, -, *, or /.";

return `The result of ${num1} ${operator} ${num2} is: ${result}`;

}
Write a javascript program to check whether entered number is prime or not.

function isPrime(num) {

// Check if the number is less than 2

if (num < 2) {

return `${num} is not a prime number.`;

// Check for factors from 2 to the square root of num

for (let i = 2; i <= Math.sqrt(num); i++) {

if (num % i === 0) {

return `${num} is not a prime number.`;

return `${num} is a prime number.`;

Write a JavaScript program that will display current date in DD/MM/YYYY format.

function getCurrentDate() {

// Create a new Date object

let currentDate = new Date();

let day = currentDate.getDate();

let month = currentDate.getMonth() + 1; // Months are 0-based in JavaScript

let year = currentDate.getFullYear();

// Format the date as DD/MM/YYYY

let formattedDate = `${day.toString().padStart(2, '0')}/${month.toString().padStart(2, '0')}/${year}`;

return formattedDate;

}
2]
3]

Write a JavaScript function that checks whether a passed string is palindrome or not.

// Function that check str is palindrome or not

function check_palindrome(str) {

let j = str.length - 1;

for (let i = 0; i < j / 2; i++) {

let x = str[i];//forward character

let y = str[j - i];//backward character

if (x != y) {

// Return false if string not match

return false;

// Return true if string is palindrome

return true;

Write JS code to perform following operation on string using split( ) Input String: “Sudha Narayan
Murthy” Display output as: First Name: Sudha Middle Name: Narayan Last Name: Murthy

// Input string

const inputString = "Sudha Narayan Murthy";

// Split the string into individual names

const names = inputString.split(" ");

console.log("First Name: " + names[0]);

console.log("Middle Name: " + names[1]);

console.log("Last Name: " + names[2]);


Explain open () method of window object with syntax and example

4]

List ways of protecting your web page and describe any one of them.

Ways of protecting Web Page:

1)Hiding your source code

2)Disabling the right MouseButton

3) Hiding JavaScript

4) Concealing E-mail address.


1) Hiding your source code

The source code for your web page—including your JavaScript—is stored in the cache, the part of
computer memory where the browser stores web pages that were requested by the visitor. A
sophisticated visitor can access the cache and thereby gain access to the web page source code.
However, you can place obstacles in the way of a potential peeker. First, you can disable use of the
right mouse button on your site so the visitor can't access the View Source menu option on the
context menu. This hides both your HTML code and your JavaScript from the visitor. Nevertheless,
the visitor can still use the View menu's Source option to display your source code. In addition, you
can store your JavaScript on your web server instead of building it into your web page. The browser
calls the JavaScript from the web server when it is needed by your web page. Using this method, the
JavaScript isn't visible to the visitor, even if the visitor views the source code for the web page.
5]
6]

You might also like