Livspace Interview Questions | Front-end SDE 1 | My Journery from 7.6LPA to 29 LPA
Anonymous User
5406

Interview Questions | Front-end | 2.2 years | Preparation time 4 months

I interviewed for 30+ companies(failed in many) and finally received 3 offers :D.
I hope these interview questions would help the front-end community on Leetcode.
I also prepared for DSA from leetcode
Leetcode count - 150 easy | 150 medium | 10 hard problems.

I will post the solutions to these questions too if I get more upvotes :D

System Design for Front-end Interviews https://leetcode.com/discuss/interview-experience/2074910/System-Design-for-Front-end-Interviews

Compensation Details https://leetcode.com/discuss/compensation/2073429/Livspace-SDE-1-UI-or-Bazaar-Voice-or-Lambda-Test

Interview Questions

  1. Implement React Context.
  2. Create a Data Structure for covid cases in state showing the state and no.of cases now show states in reverse alphabetical order.
  3. Now for the same array return second Highest case no. in state.
  4. Find values for (x^2 - x) < 0.
  5. You are given a 5L jug and a 3L jug. How would you get 4L in a jug? You are given an unlimited supply of water.
  6. What would you do if you have a project and you have to deliver it as best as possible?
  7. What does call, apply, bind do?
  8. If you have a function with params and you want to get the params in an array what should you do ?
  9. Write a duplicate function(Polyfill using Prototype)

[1,2].duplicate(); // Should return [1,2,1,2]

  1. Write a polyfill of map function.
  2. Write a polyfill of filter function.
  3. Implement this in Javascript
    $("button").addClass("change").css("background-color","yellow")
  4. Implement this in Javascript
    Print 100 buttons with nos. and click any button to alert the number. Hint : Use the concept of event bubbling/capturing to implement this.
  5. Remove duplicates from array using ES6
  6. Implement function to read field inside a nested object. (Very imp asked many times)
const obj = {
  A: {
    B: {
      C: {
        D: {
          E: 2,
        },
      },
    },
  },
};

console.log(read(obj, "A.B.C.D.E"));
// return 2 as answer if E exists else return undefined

16.Write a method sum which gives the following output sum(2)(3).
17. Five HTTP response code used for

  1. When to use PUT and POST in REST Services
  2. What is the result of 3 + 2 + "7".
  3. Output of following
(function(){    
  var a = b = 3;  
})();   
console.log("a defined? " + (typeof a !== 'undefined'));  // false
console.log("b defined? " + (typeof b !== 'undefined')); // true
  1. Output of following
const KEY = 'white_rabbit';   
if (true) {   
  const KEY = 'ginger_rabbit';   
}   
console.log(KEY); // white_rabbit
  1. What is the output of the following
let x = 42;   
if (true) {   
  console.log(x);   
  let x = 1337;   
}
  1. How would you prevent multiple actions on the same event.
  2. Have you ever received a maximum call size exceeding error? How did you resolve it?
  3. List css positions?
  4. List some pseudo classes and pseudo elements.
  5. Write a small code snippet to write a functional component which has some state in it.
    28.List some features of ES6? what do you know about arrow functions
    29.What will be the color of the text below?
 <div id =”test”>
  <span> Text </span>
</div>

div#test span { color: green; }
div span { color: blue; }
span { color: red; }
  1. What is throttling and debounce in Javascript.
  2. Create a circle in html.
  3. What is a pure component in react?
  4. How to center a div in css (Mention different ways)
    34.What is errorBoundary in React?
  5. What is Box Model in css?
  6. Explain Hoisting in Javascript.
  7. How do you lower the load time of your page in Javascript?
  8. Explain async await in JavaScript.
  9. What is prototype inheritance?
  10. What is the output of this?
  11. Write a function for input function.

input(obj,'key1', 'key2', 'key3'); // 10

  1. What is the output of this?
test1.js file contains:
var a = 20;
alert(a);
alert(b);

test2.js file contains 
alert(a);
var b = 20;
  1. What would be output if test1 is included before test2.js.
  2. How to define list-style-type in css?
  3. What would be the output of the following?
var a = 5;
var b = '5';
if (a == b)
console.log('equal');
else console.log('not equal'); // equal
  1. What would be the output of the following?
console.log([5, 7, 7, 5, 9].reduce((a, b) => a + b, 5)); //33 + 5 = 38
  1. What would be the output of the following?
const items = new Set();
items.add('ball');
items.add('bat').add('shoes').add('gloves');
console.log(items.has('bat'));
items.delete('gloves');
for(const x of items){
   console.log(x);
}
console.log(items.size());
items.clear();
console.log(items.size());
  1. You are given a kanban board with Backlog, ToDo, Ongoing and Done stages of a task. You are also given a text box in which we can add the selected task. If the task is in the backlog we can only move the task forward using the forward button until it reaches the done stage.Once it reaches done stage the forward button is disabled. If the task is in the done stage the forward button is disabled and the move backward button is enabled.

The Tasks are passed into the board Component in the following format
{1:[task1, task2],
2:[task3, task4],}

  1. Write a generator function in Javascript to print all prime nos.
  2. JSON.parse() and JSON.stringify() in JavaScript
  3. Solve the following question.
// Print values of a 
const arr =[{a:1,b:2},{a:1,c:3}];

What would happen when you try to find values of b?
52.Why is useMemo used?

  1. Calculate Sum of n numbers using closures sum(1)()(2)......
  2. Application of closures.
  3. Find MinMax from the array.
  4. Which function in js decodes the search string?
// url
www.google.com/?searchString=Hello+G%C3%BCnter
  1. How setTimeout works/ event Loop?
  2. Why are keys used in React?
  3. Explain closures.
  4. Explain the peculiar magic of flexbox and auto margin.
    61.Why does this happen in Js for the following snippet:
const Emp ={
 name:"Ya",
 company: "Ret"
}

const me = Object.create(Emp);
me.task = "Java";
delete me.company;// still shows the company name
console.log("uuu",me);

Output:
uuu {task: 'Java'} task: "Java"[[Prototype]]: Object company: "Ret"name: "Ya"[[Prototype]]: Object

62.What are the 3 different types to create an object in JavaScript?
63. What is the difference between async and defer in javascript?

  1. Explain critical rendering path.
    65.Explain local storage and session storage.
  2. What is the output of following setTimeout calls?
setTimeout(()=>console.log("b"), 5000);
setTimeout(()=>console.log("a"),0);
setTimeout(()=>console.log("i"));
console.log("yo");
// Prints yo, a ,i, b

67.Implement in Javascript to populate template object from data object.

// Populate template from data
let data = {
    name: {
        first: "Ashish",
        last: "Garg",
    },
    age: 18,
    dob: "09/03/xxx",
};

let template = {
    name: {
        first: "",
        middle: "",
        last: "",
    },
    age: 0,
    arr: [{a: "1", c: "2"}, 2, 3]
};
  1. Can you store passwords in local storage?
    69.Explain what are JWT Tokens and how are they used?

  2. Why CORS? Why the error on the client side if CORS is allowed?

  3. Explain semantic tags in HTML.

  4. Difference between HTML5 and HTML?

  5. What does !DOCTYPE do

74.What would happen for this if you only have this one div

div:before {
  font-size:12px;
  color: #000;
  background: red;
  width :50px;
  height: 50px;
  border-radius: 50px;
}

75.Why react instead of Javascript.
76. Explain Virtual Dom.

  1. Explain React Lifecycle methods.
  2. What is Use Ref in React explained with example.
    79.What would be the output of the following
console.log(false == '0'); // true
console.log(true === '1'); // false

80.What would be the order of the following children?

// HTML
<div class ='parent'>
  <div class = 'child-1'>
    ABC
  </div>
  <div class = 'child-2'>
    EFG
  </div>
  <div class = 'child-2'>
    OFD
  </div>
</div>

// CSS
.parent{
  display: flex;
}
.child-1{
  flex: 0 0 30;
}
.child-2{
  flex: 0 0 40;
  float: left;
}
.child-3{
  flex: 0 0 30;
}
  1. What would be the output of the following?
var arr1 = 'john'.split('');
var arr2 = arr1.reverse();
var arr3 = 'jones'.split('');
arr2.push(arr3);
console.log('array 1:length = '+ arr1.length + ' last = '+ arr1.slice(-1));
// Ans- array 1:length = 5 last= j,o,n,e,s

82.Write a media query to change background to red for these devices 1024px and 768px
83. Why Redux? Is Redux synchronous or asynchronous?

  1. Difference between ES6 and ES5 in Js
  2. What is inline and inline block in css?
  3. What is a span tag.
  4. Explain react hooks.
    90.Explain what happens when you type google.com (IP resolution)
  5. Explain difference between inline and inline-block
  6. What is Micro Front-end
  7. What is server side rendering
  8. How can you write CSS better
  9. Decode a2c4e2 to aaccccee in js
  10. Make a file explorer in react using a json file.
  11. Flatten an object in js

Write a function which returns a
flattened POJO (object) when given a nested POJO.

E.g. Input: 
person: {
   name: "Aditya",
   age: 14,
 },
 info: {
   medical: {
     bloodGroup: "A+",
   },
   pets: {
     dog: "bruno",
   },
 },
};

Output:
 {
   'person.name': 'Aditya',
   'person.age': 14,
   'info.medical.bloodGroup': 'A+',
   'info.pets.dog': 'bruno'
 }

Hint: Using a recursive approach might help
  1. How do you optimize performance in React?
  2. When would you use redux and context API
  3. Solve //Example input: 3, ‘ABCDEF’
    //Output: [“AB”, “CD”, “EF”]
    //Example input: 3, ‘0123456789’
    //Output: [“0123”, “4567”, “89”]
  4. Wiggle Sort 1
  5. Max length of Subarray given a target value
  6. Implement 3* 4 fluid layout with sidebar
Elements are stacked horizontally and vertically.
Elements should have equal spacing 
Elements should be in scrollable layout
It should be responsive
Sidebar will stay fixed on the left.
  1. In the snippet below print in the given order with a delay of 2000 ms. (Asked Frequently Very Important Hint: Use Async/Await with setTimeout)
main(){
 console.log(1)
 sleep();
 console.log(2)
}
  1. Draw concentric circles using css
  2. Given 100 objects remove a specific key and print object without manipulating original obj
  3. Print numbers from 10 to 1 in reverse order in one sec(use set timeout)
  4. Move zeros to left of arr
  5. Can we use useRef to store state as well. If not, why is that so?
  6. What would happen if css files took 500ms to render and called first. And the js file is called which again takes 20ms to run and the rest of the html data is rendered at last?
  7. Design the nested comment user interface.
  8. Output of the following
var x = 1;
var output = (function() {
delete x;
return x;
})();
  1. Polyfill for promise.all, reduce, bind.

Some more videos that you could refer for questions
(These are super helpful & very important)

Not only these videos some of his videos about functions, map, filter and reduce and let,var and const are super helpful

I am not promoting something here.

Some of repeated DSA problems.
1 .Capitalize first letter of each word in a sentence without using string methods (Use Prototype to implement this i.e s.capitialize1()).

  1. Wiggle Sort 1
  2. Move Zeros to Left/ Right(Repeated Many Times)
  3. Binary Search
  4. 3 Sum
  5. Group Anagrams(Repeated many times)
  6. Longest subarray sum.

These resources are also super helpful

  1. https://devtools.tech/questions/all?page=1

One more suggestion always document the questions with detailed answers you were asked in any interview. And keep revising them. After some interviews the questions keep repeating and it would help you in cracking them. (I followed a similar approach)

You can keep adding new interview questions in the comment section. I will add them if it's not already listed here.

Last but not the least Akshay Saini's Youtube channel is a gem for front-end interviews.
Keep Hustling and keep interviewing. Never give up.
I will keep the post updated as I find more questions.
Thanks A Ton :)

Comments (12)