Saturday, 24 July 2021

Minimum Index Sum of Two Lists Algorithm Javascript

Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by unique strings.

You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them in alphabetical order. 

You could assume there always exists an answer.


Example 1:

Input: list1 = [Shogun, Tapioca Express, Burger King, KFC] , list2 = [Piatti, The Grill at Torrey Pines, Hungry Hunter Steakhouse, Shogun]

Output: [Shogun]

Explanation: The only restaurant they both like is "Shogun".

Thursday, 10 June 2021

How to use componentWillUnmount with Functional Components in React

How to manage componentWillUnmount with useEffect

If you add a return function inside the useEffect function, it is triggered when a component unmounts from the DOM. This looks like:


import React, { useEffect } from 'react';

const ComponentExample => () => {

    useEffect(() => {

        return () => {

            // Anything in here is fired on component unmount.

        }

    }, [])

Thursday, 20 May 2021

Angular 8 - Communicating Between Components with Observable & Subject

 

Observable.subscribe()

The observable subscribe method is used by angular components to subscribe to messages that are sent to an observable.

Subject.next()

The subject next method is used to send messages to an observable which are then sent to all angular components that are subscribers (a.k.a. observers) of that observable.


Sunday, 16 May 2021

Render the view outside of view folder in ASP.NET mvc

 In normal case your project views(.cshtml) are in view folder of project but if you want to render the view from another folder with the same functionality of views. Then you have to just copy the web.config of views folder to your new folder and add the respective path like this.

View("~/Content/itemtemplate/Adtemplate.cshtml", model); 



Wednesday, 12 May 2021

Details Summery Tag in HTML

 The <details> tag specifies additional details that the user can open and close on demand.

The <details> tag is often used to create an interactive widget that the user can open and close. By default, the widget is closed. When open, it expands, and displays the content within.

Tip: The <summary> tag is used in conjuction with <details> to specify a visible heading for the details.


Click Here for Example