[Go to site: main page, start]

0% found this document useful (0 votes)
7 views3 pages

JavaScript Question Bank

The document is a question bank for a JavaScript unit, containing both 2-mark and 14-mark questions. It covers various topics such as scripting, data types, functions, events, form validation, and output display methods in JavaScript. The questions are designed to test knowledge and understanding of JavaScript concepts and coding practices.

Uploaded by

dearsreebalaji
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)
7 views3 pages

JavaScript Question Bank

The document is a question bank for a JavaScript unit, containing both 2-mark and 14-mark questions. It covers various topics such as scripting, data types, functions, events, form validation, and output display methods in JavaScript. The questions are designed to test knowledge and understanding of JavaScript concepts and coding practices.

Uploaded by

dearsreebalaji
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

UNIT V - JAVA SCRIPT -QUESTION BANK

[Link] 2-Mark Questions


1.​ Define scripting.
2.​ What is the purpose of the [Link]() function in JavaScript?
3.​ List any two primitive data types in JavaScript.
4.​ What is a variable in programming?
5.​ Write the syntax of an if statement in JavaScript.
6.​ Define a function in JavaScript.
7.​ What is an event in JavaScript?
8.​ Name any two mouse events in JavaScript.
9.​ What is form validation?
10.​ What keyword is used to declare a variable in JavaScript?
11.​ Differentiate between null and undefined in JavaScript.
12.​ Explain why [Link]() is preferred over alert() for debugging.
13.​ What is the difference between == and === in JavaScript?
14.​ Distinguish between a function declaration and a function expression.
15.​ Explain what happens when an if condition evaluates to false.
16.​ What is the difference between onclick and addEventListener('click',...)?
17.​ Describe the mouseover and mouseout events with an example.
18.​ Explain the significance of the return statement in a function.
19.​ What is client-side form validation? Why is it important?
20.​ Explain type coercion in JavaScript with an example.
21.​ Write a JavaScript snippet to display 'Hello World' on a webpage using
innerHTML.
22.​ Write a JavaScript function that takes two numbers and returns their sum.
23.​ Write a simple if-else statement to check if a number is even or odd.
24.​ Write JavaScript code to change the background color of a div on a button
click.
25.​ Write a JavaScript snippet to validate that a text field is not empty.
26.​ Write code to display the current date and time using JavaScript.
27.​ Write a function that returns the larger of two numbers.
28.​ Write a JavaScript snippet to show an alert if the email field does not contain
'@'.
29.​ Write code to toggle the visibility of a paragraph on a button click.
30.​ Analyze why using var inside a block does not restrict its scope to that block.
31.​ Identify the error in the following code: if x > 5 { [Link]('Yes'); }
32.​ Compare the time complexity of validating a form with one field vs. ten
fields in JavaScript.
33.​ Why does JavaScript allow a function to be called before it is declared (using
function declaration)?
34.​ Analyze the output: [Link](typeof null). What does this reveal about
JavaScript's type system?
35.​ Why is client-side validation alone insufficient for secure web applications?
36.​ Analyze this code: let x = '5' + 3; What is the output and why?
37.​ Analyze: Why does an empty string evaluate to false in an if condition?
Part B

[Link] 14-Mark Questions


1.​ List and explain the basic data types available in JavaScript with examples.
Hint: (String, Number, Boolean, Null, Undefined, Symbol, BigInt)
2.​ Write a note on displaying output in JavaScript. Explain [Link](),
[Link](), alert(), and innerHTML with examples.
3.​ Recall the syntax and usage of if, if-else, and if-else if ladder statements in
JavaScript with examples.
4.​ Define a JavaScript function. List and explain the different ways to declare
functions in JavaScript with code examples.
Hint: (Function Declaration, Function Expression, Arrow Function)
5.​ What are JavaScript events? List at least 10 commonly used events with their
descriptions.
Hint: (onclick, onmouseover, onmouseout, onchange, onload, onfocus, onsubmit,
6.​ Recall the basic rules of form validation. List the fields commonly validated in
an HTML form and name the attributes used in HTML5 for built-in validation.
Hint: (required, minlength, maxlength, pattern, type, min, max)
7.​ Explain the concept of variables in JavaScript. What are the differences between
var, let, and const? Provide examples.
8.​ Write a note on handling click events in JavaScript. Explain addEventListener()
and inline onclick with syntax and examples.
9.​ Recall any five built-in JavaScript functions used in output display and form
validation. Provide their syntax and usage.
Hint: (alert, confirm, prompt, parseInt, isNaN)
10.​ Explain the concept of data types in JavaScript with examples. How does
JavaScript's dynamic typing differ from statically typed languages?
11.​ Describe various ways to display output in JavaScript. Compare and contrast
alert(), [Link](), innerHTML, and [Link](). When should each be
used?
12.​ Explain the if-else control structure in JavaScript. Describe how nested if-else
statements work. Illustrate with a grade classification program.
Hint: (A: ≥90, B: ≥75, C: ≥60, D: ≥50, F: <50)
13.​ Describe the concept of functions in JavaScript. Explain scope (local vs global),
the return statement, and default parameters with code examples.
14.​ Explain event handling in JavaScript. Describe how events propagate (bubbling
and capturing). Illustrate with click and mouseover event examples.
15.​ Explain client-side form validation using JavaScript. Describe how to validate a
registration form with fields: Name, Email, Password, and Phone number.
16.​ Discuss variable hoisting in JavaScript. How does var behave differently from let
and const? Provide examples showing hoisting effects.
17.​ Explain how JavaScript handles truthy and falsy values in if-else conditions.
Provide at least five examples of truthy and falsy values.
18.​ Write a complete JavaScript program to perform a simple calculator that takes
two numbers and an operator (+, -, *, /) from the user using prompt() and
displays the result. Use if-else statements.
19.​ Create an HTML page with a registration form containing Name, Email,
Password, and Age fields. Write a JavaScript function to validate all fields on
form submission. Display appropriate error messages.
20.​ Write a JavaScript program using functions to find the factorial of a number
entered by the user. Display the result on the webpage using innerHTML.
21.​ Create a webpage with a button and an image. Write JavaScript code so that
when the mouse is hovered over the image, the image changes, and when the
mouse moves out, it reverts. Use onmouseover and onmouseout events.
22.​ Write a JavaScript program that uses an if-else ladder to classify a student's grade
based on marks entered in a form and displays the result dynamically on the
webpage.
23.​ Develop an interactive webpage where clicking different buttons changes the font
size, color, and style of a paragraph using JavaScript event handling with
addEventListener.
24.​ Write a JavaScript function to validate a phone number (10-digit numeric) and an
email address using regular expressions. Apply this in a contact form.
25.​ Create a simple quiz application using JavaScript: display a question with four
options as radio buttons. On clicking 'Submit', check the answer and display
'Correct' or 'Wrong'. Use if-else logic.
26.​ Write JavaScript code to display a live character counter below a textarea that
updates as the user types. Also disable the submit button if the field is empty.

You might also like