Mostly asked JavaScript interview questions!!
-
Reverse a string: Write a function that takes a string as input and returns the string in reverse order. For example, if the input is "Hello, World!", the output should be "!dlroW ,olleH".
-
Find the largest number in an array: Write a function that takes an array of numbers as input and returns the largest number in the array. For example, if the input is [3, 8, 2, 10, 5], the output should be 10.
-
Check for Palindrome: Write a function that takes a string as input and checks if it is a palindrome. A palindrome is a word or phrase that reads the same forwards and backwards. For example, if the input is "level", the output should be true.
-
FizzBuzz: Write a program that prints the numbers from 1 to 100. But for multiples of three, print "Fizz" instead of the number, and for the multiples of five, print "Buzz". For numbers that are multiples of both three and five, print "FizzBuzz".
-
Find the missing number: Given an array of numbers from 1 to N, where one number is missing, write a function to find the missing number. For example, if the input is [1, 2, 4, 5, 6], the output should be 3.
-
Remove duplicates from an array: Write a function that takes an array as input and returns a new array with duplicate elements removed. For example, if the input is [1, 2, 2, 3, 4, 4, 5], the output should be [1, 2, 3, 4, 5].
-
Check for Anagrams: Write a function that takes two strings as input and checks if they are anagrams. Anagrams are two words or phrases that use the same letters in a different order. For example, if the inputs are "listen" and "silent", the output should be true.
-
Find the longest word: Write a function that takes a sentence as input and returns the longest word in the sentence. For example, if the input is "The quick brown fox jumps over the lazy dog", the output should be "jumps".
-
Check for Prime Number: Write a function that takes a number as input and checks if it is a prime number. A prime number is a number that is only divisible by 1 and itself. For example, if the input is 7, the output should be true.
-
Count the occurrences of a character in a string: Write a function that takes a string and a character as input and returns the number of times the character appears in the string. For example, if the input is "hello", "l" the output should be 2.
Reverse Words in a String: Write a function that takes a sentence as input and returns the sentence with the words reversed. For example, if the input is "Hello, World!", the output should be "World! Hello,".
Second Largest Number: Develop a function that finds the second largest number in an array of numbers. For example, if the input is [3, 8, 2, 10, 5], the output should be 8.
Check for a Perfect Square: Create a function that checks if a given number is a perfect square (the square of an integer). For example, if the input is 16, the output should be true.
Print Even Numbers: Write a program that prints all even numbers from 1 to a given limit. For example, if the limit is 20, the output should be 2, 4, 6, 8, 10, 12, 14, 16, 18, 20.
Find Common Elements: Develop a function that finds the common elements between two arrays and returns them as a new array. For example, if the inputs are [1, 2, 3] and [3, 4, 5], the output should be [3].
Check for Armstrong Number: Create a function that checks if a given number is an Armstrong number. An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. For example, if the input is 153, the output should be true.
Remove Vowels from String: Write a function that removes all vowels from a string and returns the modified string. For example, if the input is "Hello, World!", the output should be "Hll, Wrld!".
Reverse Each Word: Develop a function that takes a sentence as input and returns the sentence with each word reversed. For example, if the input is "Hello, World!", the output should be "olleH, !dlroW".
Find nth Fibonacci Number: Create a function that finds the nth Fibonacci number using recursion. The Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, and so on.
Check for Armstrong Range: Write a program that checks for Armstrong numbers in a given range of numbers and prints the Armstrong numbers found