Skip to main content

28+ JavaScript Coding Exercises for Interviews

JavaScript Coding Exercises for Interviews:

  • Write a function to reverse a string in JavaScript.
  • Write a function to check if a string is a palindrome.
  • Write a function to find the factorial of a number recursively.
  • Write a function to calculate the Fibonacci sequence up to a given number.
  • Write a function to find the largest number in an array.
  • Write a function to find the smallest number in an array.
  • Write a function to count the number of vowels in a string.
  • Write a function to remove duplicates from an array.
  • Write a function to find the common elements in two arrays.
  • Write a function to check if two strings are anagrams of each other.
  • Write a function to sum all numbers in an array.
  • Write a function to find the missing number in a given range of numbers.
  • Write a function to implement binary search on a sorted array.
  • Write a function to merge two sorted arrays into one sorted array.
  • Write a function to find the intersection of two arrays.
  • Write a function to check if a number is prime.
  • Write a function to implement the Caesar cipher for text encryption.
  • Write a function to sort an array using the bubble sort algorithm.
  • Write a function to sort an array using the selection sort algorithm.
  • Write a function to find the longest substring without repeating characters.
  • Write a function to find the maximum subarray sum using Kadane's algorithm.
  • Write a function to generate all possible permutations of a string.
  • Write a function to implement a queue using two stacks.
  • Write a function to flatten a nested array.
  • Write a function to find the first non-repeating character in a string.
  • Write a function to convert a number to a Roman numeral.
  • Write a function to find the GCD of two numbers using Euclid's algorithm.
  • Write a function to check if a number is a perfect square.
  • Write a function to find the longest common prefix in an array of strings.
  • Write a function to implement a debounce function in JavaScript.
  • Write a function to implement a throttle function in JavaScript.
  • Write a function to generate a random integer between two given numbers.
  • Write a function to count the number of occurrences of each character in a string.
  • Write a function to deep clone an object in JavaScript.
  • Write a function to implement a simple event emitter in JavaScript.
  • Write a function to implement a deep comparison between two objects.

Comments