Skip to main content



  You make also like this CSS interview question set 1. Let's begin with set 2, 5)What is the difference between opacity 0 vs display none vs visibility hidden? Property           | occupies space | consumes clicks | +--------------------+----------------+-----------------+ | opacity: 0         |        yes      |        yes       | +--------------------+----------------+-----------------+ | visibility: hidden |        yes       |        no        | +--------------------+----------------+-----------------+ | display: none      |        no       |        no        | When we say it consumes click, that means it also consumes other pointer-events like onmousedown,onmousemove, etc. In essence "visibility: hidden" behaves like a combination of "opacity: 0" and "pointer-events: none". 6)CSS 3 new features? CSS3 allows developers to style HTML elements easier.  They are less dependent on image files  and can complete CSS styling with fewer lines of code. CSS3

Coding Interview questions set 6

Let's begin with set 6, 13)Given an array of integer nums and an integer target, return indices of the two numbers such that they add up to the target. Assumptions:  Each input would have exactly one solution, and you may not use the same element twice. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2: Input: nums = [3,2,4], target = 6 Output: [1,2] Solution: const twoSum = (nums, target) => {   const map = {};   for (let i = 0; i < nums.length; i++) {     const another = target - nums[i];     if (another in map) {       return [map[another], i];     }     map[nums[i]] = i;   }   return null; }; You may also like these articles:   Coding Interview Set 1     Coding Interview Set 2 .     Coding Interview Set 3   Coding Interview Set 4 14)Given an array of numbers containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Could you impleme

Node.js: create an excel file with multiple tabs.

This article is a sample code to generate an excel file with multiple tabs using  excel4node  module. Install: npm i excel4node Let's see the sample code, var excel = require( 'excel4node' ); // Create a new instance of a Workbook class var workbook = new excel.Workbook(); // Add Worksheets to the workbook var worksheet = workbook.addWorksheet( 'Buy order types' ); var worksheet1 = workbook.addWorksheet( 'Sell order types' ); // Style for headers var style = workbook.createStyle({ font : { color : '#EA3A14' , size : 18 }, numberFormat : '$#,##0.00; ($#,##0.00); -' }); var styleForData = workbook.createStyle({ font : { color : '#47180E' , size : 12 }, alignment : { wrapText : true , horizontal : 'center' , }, numberFormat : '$#,##0.00; ($#,##0.00); -' }); let buyOrderTypes = [ {name : "buy" ,id : "1" ,comment : "Normal

Coding Interview Questions set 5

  Let's begin with set 5, Q11)Valid Parentheses problem. Given a string s containing only the characters '(', ')', '{', '}', '[' and ']',  determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Examples : a)Input: s = "()" Output: true Example 2: b)Input: s = "()[]{}" Output: true Example 3: c)Input: s = "(]" Output: false Solution: var isValid = function(s) {    const obj={             "}":"{",             "]":"[",             ")":"(",         },     var stack=[];            for(let i=0;i<s.length;i++){        if(s[i] in obj) {           if(!stack.length || stack[stack.length-1]!==obj[s[i]]) {               return false;            }           else stack.pop();      }else stack.push(s[i]);   }  return !stack.length; }; L

Data structure problem 1:Implement a queue using 2 stacks.

This is one of the interview questions asked in technical or data structure round. As we know stack is first in last out and queue is first in first out. Here we have to implement the behaviour of queue using 2 stacks. So let's begin with one of the approaches, For 2 stacks we have define 2 arrays; var stack1=[]; var stack2=[]; For insertion or push, we will use stack1. For any insertion, we can push it in stack1 array. a)Insert "A" stack1.push("A"); b)Insert "B" stack1.push("B"); c)Insert "C" stack1.push("C"); Now when we remove or pop, the first pushed element should be removed first i.e behaviour of a queue.    So if we poped from stack1 we will get the behaviour of stack here. stack1.pop()//"C" will be removed i.e behaviour of stack last in first out. We can't use this, so we will need stack2 for this purpose to implement the behaviour of the queue. d)Remove or pop: For first remove or pop, we will need

javascript snippets interview questions set 3

  For the previous set please refer to  javascript snippets questions set 2. Let's  begin with set 3, Q12)After the following code, what is the value of a.length? var a = ['dog', 'cat', 'hen']; a[100] = 'fox'; a) 101 b) 3 c) 4 d) 100 Q13)What is the value of dessert.type after executing this code? const dessert = { type: 'pie' }; dessert.type = 'pudding'; a) pie b) The code will throw an error. c) pudding d) undefined Q14)Why would you include a "use strict" statement in a JavaScript file? a) to tell parsers to interpret your JavaScript syntax loosely b) to tell parsers to enforce all JavaScript syntax rules when processing your code c) to instruct the browser to automatically fix any errors it finds in the code d) to enable ES6 features in your code Q15)Which variable is an implicit parameter for every function in JavaScript? a) Arguments b) args c) argsArray d) argumentsList I hope you like the article. Please stay connect

javascript snippets interview questions set 2

For the previous set please refer to javascript snippets questions set 1. Let's  begin with set 2, Q6)What is the result of running this code? sum(10, 20); diff(10, 20); function sum(x, y) {   return x + y; } let diff = function (x, y) {   return x - y; };  a) 30, ReferenceError, 30, -10  b) 30, ReferenceError  c) 30, -10  d) ReferenceError, -10 Q7)Which of the following values is not a Boolean false?  a) Boolean(0)  b) Boolean("")  c) Boolean(NaN)  d) Boolean("false") Q8)For the following class, how do you get the value of 42 from an instance of X? class X {   get Y() {     return 42;   } } a) x.get('Y') b) x.Y c) x.Y() d) x.get().Y  Q9)What's one difference between the async and defer attributes of the HTML script tag?  a) The defer attribute can work synchronously.  b) The defer attribute works only with generators.  c) The defer attribute works only with promises.  d) The defer attribute will asynchronously load the scripts in order. Q10)What val

javascript snippets interview questions set 1

  Hey, I have just started a new set for javascript snippets  interview questions which will make your understanding of javascript more clear. It's more like testing your knowledge and then clearing things that you have doubt or if you have heard for the first time about it. So let's begin with testing and improving yourself, Q1. Which operator returns true if the two compared values are not equal?  a)<>  b)~  c)==!  d)!== Q2. How is a forEach statement different from a for a statement?  a)Only a for statement uses a callback function.  b)A for statement is generic, but a forEach statement can be used only with an array.  c)Only a forEach statement lets you specify your own iterator.  d)A forEach statement is generic, but a for statement can be used only with an array. Q3. Which statement creates a new object using the Person constructor?  a)var student = new Person();  b)var student = construct Person;  c)var student = Person();  d)var student = construct Person(); Q4. W

Node.js (v.15) 4 things to know.

  The V8 JavaScript engine has been updated to V8 8.6  (V8 8.4 is the latest available in Node.js 14).  Along with performance tweaks and improvements the V8 update also brings  the following language features: 1)Promise.any(): Promise.any() takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfills,  returns a single promise that resolves with the value from that promise.  If no promises in the iterable fulfill (if all of the given promises are rejected),  then the returned promise is rejected with an AggregateError. Example: const promise1 = Promise.reject(0); const promise2 = new Promise((resolve) => setTimeout(resolve, 100, 'quick')); const promise3 = new Promise((resolve) => setTimeout(resolve, 500, 'slow')); const promises = [promise1, promise2, promise3]; Promise.any(promises).then((value) => console.log(value)); 2)AggregateError: The AggregateError object represents an error when several errors need to be wrapped i

Coding Interview Questions set 4

Let's begin with set 4, 9)Find the majority Element? Given an array of size n, find the majority element.  The majority element is the element that appears more than  n/2 times. Assumptions: You may assume that the array is non-empty and the majority element always exists in the array. Example 1: Input: [4,2,4] Output: 4 Example 2: Input: [3,3,1,1,1,3,3] Output: 3 Solution: var majorityElement = function(nums) { var obj = {}; for(var i = 0; i < nums.length; i++){ obj[nums[i]] = obj[nums[i]] + 1 || 1; if(obj[nums[i]] > nums.length / 2) { return nums[i]; }  }}; Logic: We have used an object map for maintaining the count.            You may also like this articles:   Coding Interview Set 1     Coding Interview Set 2 .     Coding Interview Set 3 10)Check if two strings are an anagram of each other? 2 words are anagram if 2nd word is formed by rearranging the letters from 1st word.   Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input:

Javascript interview questions set 2

For set 1 please refer to the  Javascript interview question set 1. Let's begin with set 2, 3)What is the difference between Object.seal() and Object.freeze() in JavaScript? Object.seal() method protects the deletion of an existing property  but it can't protect the existing properties from outside changes.  var object1 = {       prop1: 1   };   Object.seal(object1);   object1.prop1 = 2; // value got changed   delete object1.prop1;   console.log(object1)   //It will show value of prop1=2.    We can't delete the property. It can just be modified. In addition to the functionalities of Object.seal(), The Object.freeze() method even won't allow minute changes to the existing properties of an object.  var object1 = {       prop1: 1   };  Object.freeze(object1);  object1.prop1 = 2;   delete object1.prop1;  console.log(object1)  It will show the value of prop1=1.   We can't delete any property or modify any property. 4)What is negative infinity? The negative infinity in Ja