BHARATI VIDYAPEETH INSTITUTE OF TECHNOLOGY
QUESTION BANK
Unit Test-I (Shift:-I & II)
Program : - Computer Engineering Group Program Code:-
CM/IF Course Title: -Client Side Scripting
Language Semester: - Fifth
Course Abbr &Code:-CSS (22519) Scheme: I
------------------------------------------------------------------------------------------------
CHAPTER-1 (Basics of JavaScript Programming) (CO1)
2 MARKS
1. Explain any two features of JavaScript.
1) JavaScript is a lightweight, interpreter programming language
2) JavaScript is a scripting language and it is not java
2. Compare client-side and server-side scripting.
Sr no. Client-side Scripting Server-side Scripting
1. This script executes on client-side, (on On other hand this script executes on
user computer where browser running) server-side, (on computer where web site
so called client side scripting. running) so called server side scripting.
2. Less secure. This is more secure than client side
scripting as business logic and code written
is not visible to user.
3. It runs on client-side thus if user Faster as it runs on server which is highly
computer is slow script will also work configured machine.
slowly
4. JavaScript (JQuery), VBScript are PHP, ASP.NET, JSP etc technologies are
widely used for this purpose. widely used for this purpose
3. List types of operators in JavaScript.
There are 5 types of operators in JavaScript:
1) Arithmetic Operators.
2) Comparison Operators.
3) Logical Operators.
4) Bitwise Operators.
5) Assignment Operators.
4 MARKS
1. Explain six types of values in JavaScript.
Values or Literals:
You use literals to represent values in JavaScript. These are fixed values, not variables, that
you provide in your script.
This section describes the following types of literals:
1. Array literals
2.Boolean literals
3. Floating-point literals
4. Integers
5. String literals.
Array Literals:
An array literal is a list of zero or more expressions, each of which represents an array
element, enclosed in square brackets ([]).
When you create an array using an array literal, it is initialized with the specified
values as its elements, and its length is set to the number of arguments specified.
The following example creates the coffees array with three elements and a length of
three:
var coffees ['French Roast', 'Colombian', 'Kona'];
Boolean Literals:
The Boolean type has two literal values namely, true and false.
Integers:
Integers can be expressed in decimal (base 10), hexadecimal (base 16), octal (base 8)
and binary (base 2).
Decimal integer literal consists of a sequence of digits without a leading 0 (zero).
Leading 0 (zero) on an integer literal, or leading 00 (or 00) indicates it is in octal.
Octal integers can include only the digits 0-7.
Leading Ox (or OX) indicates hexadecimal. Hexadecimal integers can include digits
(0-9) and the letters a-f and A-F.
Leading Ob (or OB) indicates binary. Binary integers can include digits only 0 and 1.
Some examples of integer literals are:
0, 117 and -345 (decimal, base 10)
015, 0001 and -0077 (octal, base 8)
0x1123, 0x00111 and -0xF1A7 (hexadecimal, "hex" or base 16)
0b11, ebee11 and -eb11 (binary, base 2)
Floating Point Literals:
A floating-point literal can have the following parts:
o A decimal integer which can be signed (preceded by "+" or "-"),
o A decimal point ("."),
o A fraction (another decimal number),
o An exponent.
The exponent part is an "e" or "E" followed by an integer, which can be signed
(preceded by "+" or "-"). A floating-point literal must have at least one digit and either
a decimal point or "e" (or "E").
Some example of floating point literals are: 17.5, 6.002E21.
String Literals:
A string literal is zero or more characters enclosed in double (") or single (') quotation
marks.
A string must be delimited by quotation marks of the same type; that is, either both
single quotation marks or both double quotation marks.
The following are examples of string literals:
'Nirali'
"Prakashan"
'1234'
'one line \n another line'
You can call any of the methods of the String object on a string literal value-
JavaScript automatically converts the string literal to a temporary String object, calls
the method, then discards the temporary String object.
2. Compare client-side and server-side scripting.
Sr no. Client-side Scripting Server-side Scripting
1. This script executes on client-side, (on On other hand this script executes on
user computer where browser running) server-side, (on computer where web site
so called client side scripting. running) so called server side scripting.
2. Less secure. This is more secure than client side
scripting as business logic and code written
is not visible to user.
3. It runs on client-side thus if user Faster as it runs on server which is highly
computer is slow script will also work configured machine.
slowly
4. JavaScript (JQuery), VBScript are PHP, ASP.NET, JSP etc technologies are
widely used for this purpose. widely used for this purpose
3. Write a JavaScript program to display squares of 1 to 10 numbers using while loop.
let number = 1;
while (number <= 10) {
console.log("The square of " + number + " is " + (number * number));
number++;
}
4. Write a JavaScript program to generate Armstrong number between 1 to 100.
for (let number = 1; number <= 100; number++) {
let sum = 0;
let temp = number;
let numberOfDigits = number.toString().length;
while (temp > 0) {
let digit = temp % 10;
sum += Math.pow(digit, numberOfDigits);
temp = Math.floor(temp / 10);
}
if (sum === number) {
console.log(number + " is an Armstrong number.");
}
}
CHAPTER-2 (Array, Function and String) (CO2)
2 MARKS
1.syntax for defining the function.