Front end Developer

700+ Front end Developer Interview Questions and Answers

Updated 10 Dec 2024

Popular Companies

search-icon
Q1. Non-Decreasing Array

You have been given an integer array/list 'ARR' of size 'N'. Write a solution to check if it could become non-decreasing by modifying at most 1 element.

We define an array as non-decreasing,...read more

Ans.

The solution checks if an integer array can become non-decreasing by modifying at most one element.

  • Iterate through the array and check if there are more than one decreasing pairs of elements.

  • If there are more than one decreasing pairs, return false.

  • If there is only one decreasing pair, check if modifying one of the elements can make the array non-decreasing.

  • If modifying the element at index i-1 or i can make the array non-decreasing, return true.

  • Otherwise, return false.

Q2. Find Unique

You have been given an integer array/list(ARR) of size N. Where N is equal to [2M + 1].

Now, in the given array/list, 'M' numbers are present twice and one number is present only once.

You need to fi...read more

Ans.

The task is to find the unique number in an array where all other numbers occur twice.

  • The array size is given by N = 2M + 1, where M is the number of elements occurring twice.

  • Loop through the array and use a hashmap to count the occurrences of each number.

  • Return the number with a count of 1, as it is the unique number.

Front end Developer Interview Questions and Answers for Freshers

illustration image
Q3. Dijkstra's shortest path

You have been given an undirected graph of ‘V’ vertices (labelled from 0 to V-1) and ‘E’ edges. Each edge connecting two nodes u and v has a weight denoting the distance between them.

Yo...read more

Ans.

The question is about finding the shortest path distance from a source node to all vertices in an undirected graph.

  • The graph is represented by the number of vertices and edges, followed by the edges and their distances.

  • The task is to find the shortest path distance from the source node (0) to all other nodes.

  • If a node is disconnected from the source node, print the maximum positive integer value (2147483647).

  • Implement the function and return the shortest path distances in asc...read more

Q4. Encode N-ary tree to binary tree

You have been given an N-ary tree ‘N’ nodes with node ‘1’ as head of the tree. Encode the above N-ary tree into a binary tree such that if only the encoded binary tree was given ...read more

Ans.

The task is to encode an N-ary tree into a binary tree and then decode the binary tree back into the original N-ary tree.

  • Encode the N-ary tree by representing each node as a binary tree node with its first child as the left child and subsequent children as the right child.

  • To decode the binary tree, traverse the binary tree and for each node, create a new N-ary tree node with its left child as the first child and subsequent right children as siblings.

  • Use a level order traversa...read more

Are these interview questions helpful?
Q5. Sort Linked List

You are given a Singly Linked List of integers which is sorted based on absolute value.

You have to sort the Linked List based on actual values.

The absolute value of a real number x, denoted |...read more

Ans.

The task is to sort a singly linked list based on actual values instead of absolute values.

  • Traverse the linked list and store the values in an array

  • Sort the array using any sorting algorithm

  • Create a new linked list using the sorted array

  • Return the new linked list

Q6. Sort Array

You are given an array consisting of 'N' positive integers where each integer is either 0 or 1 or 2. Your task is to sort the given array in non-decreasing order.

Note :
1. The array consists of only ...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop
Q7. Check If Linked List Is Palindrome

You are given a Singly Linked List of integers. You have to find if the given linked list is palindrome or not.

A List is a palindrome if it reads the same from the left to the...read more

Q8. Check If Path Exists

You are given a directed and unweighted graph of 'V' vertices and 'E' edges. All edges are given in a 2-dimensional array ‘Edges’ in which ‘Edges[i][0]’ and ‘Edges[i][1]’ contain an edge. Yo...read more

Ans.

The task is to check if there exists a path from a given source vertex to a destination vertex in a directed and unweighted graph.

  • Read the number of test cases.

  • For each test case, read the number of vertices and edges.

  • Read the edges of the graph.

  • Read the source and destination vertices.

  • Implement a graph traversal algorithm (e.g., BFS or DFS) to check if a path exists from the source to the destination.

  • Print 'true' if a path exists, otherwise print 'false'.

Front end Developer Jobs

Frontend Developer 2-5 years
IBM India Pvt. Limited
4.1
Bangalore / Bengaluru
Front End Developer - Reactjs 6-9 years
Cognizant
3.8
Pune
Front End Developer- Angular.js 6-10 years
Cognizant
3.8
Kolkata
Q9. Magic Index

You are given a sorted array A consisting of N integers. Your task is to find the magic index in the given array.

Note :
A magic index in an array A[0 ... N - 1] is defined to be an index i such that...read more
Q10. Diameter Of Binary Tree

You are given a Binary Tree. You are supposed to return the length of the diameter of the tree.

The diameter of a binary tree is the length of the longest path between any two end nodes i...read more

Ans.

The diameter of a binary tree is the length of the longest path between any two end nodes in the tree.

  • The diameter of a binary tree can be calculated by finding the maximum of the following three values: 1) the diameter of the left subtree, 2) the diameter of the right subtree, and 3) the longest path that passes through the root node.

  • To find the diameter of a binary tree, we can use a recursive approach. We calculate the height of the left and right subtrees, and then calcul...read more

Q11. Check If The String Is A Palindrome

You are given a string 'S'. Your task is to check whether the string is palindrome or not. For checking palindrome, consider alphabets and numbers only and ignore the symbols ...read more

Q12. Merge K Sorted Arrays

You have been given ‘K’ different arrays/lists, which are sorted individually (in ascending order). You need to merge all the given arrays/list such that the output array/list should be sor...read more

Q13. Remove Duplicates

Ninja is playing with numbers but hates when he gets duplicate numbers. Ninja is provided an array, and he wants to remove all duplicate elements and return the array, but he has to maintain th...read more

Q14. Reverse the order of words in a string

You are given a string ‘STR’ containing space-separated words. A word is a sequence of non-space characters. Your task is to reverse the order of words in ‘STR’.

Note: Try ...read more

Q15. Allocate Books

Given an array ‘arr’ of integer numbers . where ‘arr[i]’ represents the number of pages in the ‘i-th’ book. There are ‘m’ number of students and the task is to allocate all the books to their stud...read more

Q16. Technical Questions

Get the frogs and the lilypads line up in order (e.g. yellow lilypad is the first among all other lilypads and yellow frog is first among all other frogs) using flex-direction.

Arrange the fr...read more

Q17. Rotate Linked List

You have been given a Linked List having ‘N’ nodes and an integer ‘K’. You have to rotate the Linked List by ‘K’ positions in a clockwise direction.

Example :

 Given Linked List : 1 2 3 4 -1 a...read more
Q18. Segregate Odd-Even

There is a wedding ceremony at NinjaLand. The bride and groom want everybody to play a game and thus, they have blindfolded the attendees. The people from the bride’s side are holding odd numb...read more

Q19. Most Frequent Word

You are given a paragraph that may have letters both in lowercase and uppercase, spaces, and punctuation. You have also given a list of banned words. Now your task is to find the most frequent...read more

Q20. Swap Two Numbers

Take two numbers as input and swap them and print the swapped values.

Input Format:
The first line of input contains a single integer 't', representing the total number of test cases. The second...read more
Q21. Triplets with Given Sum

You are given an array/list ARR consisting of N integers. Your task is to find all the distinct triplets present in the array which adds up to a given number K.

An array is said to have a...read more

Frequently asked in,

Q22. How to redirect to login page through React Router if the user has not logged in and trying to go to another page through URL.

Ans.

Use React Router's Redirect component to redirect to login page if user is not logged in.

  • Create a PrivateRoute component that checks if user is logged in

  • If user is not logged in, redirect to login page using Redirect component

  • Wrap the routes that require authentication with PrivateRoute component

Q23. Chocolate Problem

Given an array/list of integer numbers 'CHOCOLATES' of size 'N', where each value of the array/list represents the number of chocolates in the packet. There are ‘M’ number of students and the t...read more

Frequently asked in,
Q24. Assignment

You are given a webpage design and you have to code the same using html, CSS, core Js

Ans.

The candidate is asked to code a given webpage design using HTML, CSS, and core JavaScript.

  • Understand the webpage design thoroughly before starting the coding process.

  • Use HTML to structure the content of the webpage.

  • Apply CSS to style the webpage according to the design.

  • Utilize core JavaScript to add interactivity and functionality to the webpage.

  • Ensure cross-browser compatibility and responsiveness of the webpage.

  • Test the webpage thoroughly to identify and fix any bugs or is...read more

Q25. How can you only accept jpg and png files using HTML5.

Ans.

Use the 'accept' attribute in the input tag to specify accepted file types.

  • Add the 'accept' attribute to the input tag.

  • Set the value of the 'accept' attribute to 'image/jpeg, image/png'.

Q26. Matching Prefix

You are given an integer ’N’ denoting the length of the array ‘Arr’ of strings made up of lower case English alphabets. The cost of this array is equal to the sum of length of each string in the ...read more

Q27. Alien dictionary

You have been given a sorted (lexical order) dictionary of an alien language. Write a function that finds the order of characters in the alien language. This dictionary will be given to you in t...read more

Q28. LRU Cache Implementation

Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:

1. get(key) - Return the value of the key if the key exists in the cache, o...read more
Frequently asked in,
Q29. Technical Questions

First, he asked me about different meta tags in HTML and different types of CSS media queries.

Then he asked me questions about Promise and async-await. I need to create a function that takes ...read more

Q30. Technical Questions

How would you handle transaction failures?
How can we check if the transaction happening is a genuine or fraud?
What was your role in your resume projects? Why and when did you coded it?

Ans.

To handle transaction failures, implement error handling and rollback mechanisms. To check for fraud, use fraud detection algorithms and verification processes. Role in projects: coding, testing, and deployment.

  • Implement error handling and rollback mechanisms to handle transaction failures

  • Use fraud detection algorithms and verification processes to check for fraud

  • Role in projects: coding, testing, and deployment

  • Projects coded as per requirements and timeline

Q31. Jumping Numbers

You are given a positive integer N, your task is to find all the Jumping Numbers smaller than or equal to N.

A number is defined as a Jumping Number if all adjacent digits in it have an absolute ...read more

Q32. Designing Question

I was told to build a compound interest calculator where we need to store the previous calculation, ability to modify/delete them. There were 2 bonus features like store data in local storage ...read more

Q33. Technical Questions

How do you ensure that your website design or web application is accessible and user-friendly? How do you structure your CSS and JavaScript to make it easier for other developers to work with...read more

Q34. Postorder Successor

You are given a binary tree having ‘N’ distinct nodes and an integer ‘M’, you have to return the postorder successor of ‘M’.

Note:

The postorder successor of ‘M’ is defined as the next elemen...read more
Q35. String Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters.

Palindrome
A palindrome is a word, number, phrase, or other sequences of characters which read the sam...read more
Q36. Program for Priority CPU Scheduling | Set 1

You are given the ‘N’ processes with their “burst times”, and the “arrival time” for all processes is ‘0’. You are also given the ‘priority’ of each process.

Your task...read more

Q37. Technical Questions

What are the different lifecycle methods in React?

Explain Strict Mode in React.

How to prevent re-renders in React?

Ans.

Lifecycle methods in React, Strict Mode, and preventing re-renders.

  • Lifecycle methods in React include componentDidMount, componentDidUpdate, componentWillUnmount, etc.

  • Strict Mode is a tool for highlighting potential problems in React components.

  • To prevent re-renders in React, use shouldComponentUpdate or React.memo.

Q38. JavaScript Question

What happens when you call a function with the new keyword?

Q39. Frontend Development Questions

Create a Stopwatch using HTML, CSS, and JS

Create an input form using HTML, CSS, and JS

Create some basic structure using HTML, CSS, and JS. I can't remember it but it was also some ...read more

Q40. How to center align a div in just one line in css.

Ans.

Use flexbox to center align a div in just one line in CSS.

  • Set the parent container's display property to flex.

  • Use the justify-content property with the value 'center' to horizontally center the div.

  • Use the align-items property with the value 'center' to vertically center the div.

Q41. JavaScript Question

What are the data types in Javascript?

Q42. HTML Question

What are the features of HTML-5?

Q43. Is Javascript single thread or multithread?

Ans.

Javascript is single-threaded.

  • Javascript runs on a single thread called the event loop.

  • This means that it can only execute one task at a time.

  • However, it can delegate tasks to other threads using web workers.

  • This allows for parallel processing without blocking the main thread.

Q44. JavaScript Question

What is the return type of getElementsByClass method?

Q45. implement a calculator class which does this cal.add(2).sub(3).mul(4).delay(2000).add(4) etc

Ans.

Implement a calculator class with chaining methods and delay function.

  • Create a Calculator class with add, sub, mul methods that return the instance of the class.

  • Implement a delay method that uses setTimeout and returns the instance of the class.

  • Use a queue to store the operations and execute them in order after the delay.

  • Return the result of the operations when the equals method is called.

Q46. Javascript Question

What is Prototype Chaining in JS?

Q47. Javascript Questions

1) What is currying in Javascript?

2) Explain hoisting with a code snippet.

3) What does this return (typeof null) ?

4) What is callback hell?

Q48. Assignment

We were given a Figma link for a landing page of a website. We need to pixel-perfect that design.

Q49. JavaScript Question

How can you import all exports of a file as an object in JavaScript?

Q50. JavaScript Question

What is the typeof() operator?

1
2
3
4
5
6
7
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10k Interviews
3.9
 • 7.8k Interviews
3.7
 • 7.3k Interviews
3.8
 • 5.4k Interviews
3.7
 • 5.2k Interviews
3.8
 • 4.6k Interviews
3.6
 • 3.6k Interviews
4.0
 • 750 Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

Front end Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter