0% found this document useful (0 votes)
8 views2 pages

Beginner JavaScript Test Questions

The document outlines a Beginner JavaScript Test consisting of four sections: Multiple Choice, Short Answer, Output Based, and Practical/Coding, totaling 50 marks. Each section assesses different aspects of JavaScript knowledge, including DOM manipulation, function creation, and control structures. The marking scheme specifies the distribution of marks across the sections.

Uploaded by

nawav81331
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)
8 views2 pages

Beginner JavaScript Test Questions

The document outlines a Beginner JavaScript Test consisting of four sections: Multiple Choice, Short Answer, Output Based, and Practical/Coding, totaling 50 marks. Each section assesses different aspects of JavaScript knowledge, including DOM manipulation, function creation, and control structures. The marking scheme specifies the distribution of marks across the sections.

Uploaded by

nawav81331
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

Beginner JavaScript Test (Total: 50 Marks)

Section A – Multiple Choice (10 Marks, 2 marks each)


1. Which of the following is used to select an element by its ID in the DOM?
a) [Link]()
b) [Link]()
c) [Link]()
d) [Link]()
2. What is the correct way to create a function in JavaScript?
a) function = myFunction()
b) function myFunction() { }
c) func myFunction() { }
d) def myFunction() { }
3. Which loop is best when you know the exact number of iterations?
a) while
b) for
c) do...while
d) switch
4. [Link]('.myClass') will:
a) Select all elements with class name myClass
b) Select the first element with class name myClass
c) Throw an error
d) Select elements by ID
5. Which operator is used to compare both value and type?
a) ==
b) ===
c) !=
d) =

Section B – Short Answer (15 Marks, 3 Marks Each)


6. Explain the difference between var, let, and const with one example of each.
7. Write a JavaScript program that prints all numbers from 1 to 10 using a for loop.
8. What is the difference between if...else and switch statements? Give an example where switch is
better.
9. Write a JavaScript function greet(name, time) that takes a name and a time of day (like 'morning',
'afternoon' or 'evening') and returns a message like 'Good morning, John!' or 'Good evening, Sara!'.
(Hint: Use string concatenation or template literals.)
10. How can you change the text of a tag with id 'para' to 'Welcome to Vinia!' using DOM?

Section C – Output Based (10 Marks, 2 Marks Each)


11. Predict the output:
let x = 5;
let y = '5';
[Link](x == y);
[Link](x === y);
12. Predict the output:
for (let i = 1; i <= 3; i++) {
[Link](i * 2);
}
13. Predict the output:
function test(a = 10, b = 5) {
return a + b;
}
[Link](test(3));
14. Predict the output:
let colors = ['red', 'green', 'blue'];
[Link](colors[1]);
[Link]('yellow');
[Link]([Link]);
15. Predict the output:
let num = 10;
if (num > 5 && num < 15) {
[Link]('Yes');
} else {
[Link]('No');
}

Section D – Practical / Coding (15 Marks)


16. (5 Marks) Create a button in HTML. When it is clicked, change the background color of the page
to light blue using JavaScript.
17. (5 Marks) Write a JavaScript function that takes an array of numbers and returns the sum of all
numbers greater than 10.
18. (5 Marks) Using prompt(), ask the user for a number. If the number is even, show an alert 'Even
Number', otherwise 'Odd Number'.

Marking Scheme:
Section A: 5 questions × 2 marks = 10
Section B: 5 questions × 3 marks = 15
Section C: 5 questions × 2 marks = 10
Section D: 3 questions (5 marks each) = 15
Total = 50 Marks

You might also like