TGJSTest1

 


JavaScript Coding and Theory Test

Duration: 2.5 Hours

Total Marks: 100

Instructions:

  • This test consists of two sections: JavaScript Theory and JavaScript Coding Challenges.
  • Answer all questions in the given time frame.
  • Each question carries 5 marks, except for a few have marks it carries.
  • Write your answers in the spaces provided.
  • Ensure your code is clear, well-documented, and error-free.
  • Plagiarism or using external resources is strictly prohibited.

Section 1: JavaScript Theory (30 Marks) [30 Minutes]

 1 What is JavaScript, and what are its key features?

 2 Explain the differences between var, let, and const for variable declarations in JavaScript.

 3 Describe the event loop and how it works in JavaScript.

 4 What is a closure in JavaScript, and why is it useful?

 5 (10 Marks): Explain the purpose of callbacks and promises in asynchronous JavaScript.

6 Write a JavaScript function that checks if a given string is a palindrome.

 7 Create a function that accepts an array of numbers and returns the sum of all even numbers.

 8 Write a function that reverses a string without using built-in reverse methods.

 9 Explain the concept of hoisting in JavaScript and provide an example.

 10 (10 Marks): What is the difference between == and === in JavaScript? Provide an example.

11 Describe what "prototypal inheritance" means in JavaScript and how it differs from classical inheritance.

 12 What is the purpose of the “this” keyword in JavaScript, and how does its value change depending on the context?

 13 Explain the concept of a "closure" in JavaScript and provide a practical use case.

 14 Compare and contrast asynchronous programming using callbacks and Promises in JavaScript.

 15 (10 Marks): What are arrow functions in JavaScript, and how do they differ from regular functions?


Section 4: JavaScript Coding Challenges (30 Marks) [30 Minutes]

 16 Write a JavaScript function that takes an array of numbers as input and returns the largest number in the array.

 17 Create a function that finds and returns the first non-repeated character in a given string.

 18 Implement a simple JavaScript calculator that can perform addition, subtraction, multiplication, and division operations.

 19 Write a function that flattens a nested array in JavaScript.

 20 (10 Marks): Implement a function to find the Fibonacci sequence up to a given number using recursion.

21 Write a JavaScript function that checks if a given word is an anagram of another word.

 22 Create a function that finds and returns the intersection of two arrays in JavaScript.

 23 Implement a function that converts a given amount of money (in dollars) into the minimum number of coins.

 24 Write a function that generates a random password with a specified length.

 25 Create a JavaScript function that checks if a given number is prime.

 26 Implement a function that calculates the factorial of a given positive integer using recursion.

 27 Write a JavaScript function that validates an email address based on common email format rules.

 28 Develop a function that finds and returns the longest word in a given sentence.

 29 Implement a JavaScript function that sorts an array of strings in alphabetical order.

 30 Create a function that takes a sorted array and a target value and returns the index of the target value using binary search.


End of Test Paper

Good luck with your test!!

 

Comments

Popular posts from this blog

FrontEnd - FAQs - Part 1

Java Script - FAQs

CoreJava - ClassesObjectsMethods - Assignment