Grade 7
Chapter : JavaScript: An Introduction
Learning Objectives:
● Understand what JavaScript is
● Learn how to declare and use variables
● Use basic operators
A. Tick (✓) the Correct Option
✅
1. JavaScript is an________ driven scripting language:
a. event
✅ b. LiveScript
2. JavaScript was originally called:
✅ b. String
3. __________ holds characters or a combination of letters:
✅ a. interactivity
4. JavaScript can add __________ to web pages:
5. Variables in JavaScript must begin with a letter, underscore (_) or __________
✅
character:
b. dollar ($)
✅ c. variables
6. Assigning value to a variable is known as __________ initialization:
2
B. Write ‘T’ for True and ‘F’ for False
1. Numeric variable holds only number values.
❌ False (In JavaScript, variables are loosely typed and can hold any type)
2. JavaScript is not case-sensitive.
❌ False
JavaScript is case-sensitive. For example, Name and name are treated as
different variables.
3. JavaScript variables must begin with a letter only.
❌ False
JavaScript variables can begin with a letter, underscore _, or dollar sign $.
4. The prompt() method is used to give the output to the user.
❌ False
The prompt() method is used to get input from the user, not to give output.
5. The sqrt() function in JavaScript returns the cube root of a number.
❌ False
The [Link]() function returns the square root, not cube root.
For cube root, use [Link]().
C. Fill in the Blanks
1. JavaScript was developed by Brendan Eich in the mid-1990s.
2. JavaScript is a scripting language.
3. [Link] command is used for writing output to a page.
4. JavaScript uses variables to store values temporarily in internal memory.
5. [Link]() function is used to return the largest number from multiple
numbers.
3
D. Define the following
1. JavaScript blocks:
JavaScript blocks are sections of code grouped together using curly braces {}.
2. Operators:
Operators are special symbols used to perform operations like addition (+),
subtraction (-), multiplication (*), etc.
E. Differentiate
Alert Box Confirm Box
Displays a message with an OK button only. Displays a message with OK and Cancel buttons.
Used to inform the user. Used to confirm an action from the user.
F. Answer the Following Questions
1. Write two advantages of JavaScript.
It adds interactivity to web pages.
It runs on the client side, reducing server load.
2. 2. How can JavaScript be added in a web page?
JavaScript can be added using the <script> tag:
<script type="text/javascript">
// JavaScript code here
</script>
4
3. What is JavaScript statement?
A JavaScript statement is an instruction that the browser executes, like
alert("Hello");.
4. How are variables declared and initialized in JavaScript?
Variables are declared using var, let, or const.
Example: var name = "John";
G. Answer Briefly
1. What is a function? Write its type.
A function is a block of code designed to perform a particular task.
Types:
● Built-in Functions (e.g., alert(), prompt(), [Link]())
● User-defined Functions
2. Write the rules of naming a variable in JavaScript.
● Variable names must begin with a letter, underscore _, or dollar sign $.
● They can contain letters, digits, underscores, and dollar signs.
● JavaScript is case-sensitive (e.g., name and Name are different).
● Reserved keywords cannot be used as variable names.
3. How do we add comment in JavaScript?
● Single-line comment: // This is a comment
● Multi-line comment: /* This is a multi-line comment */