Find Interaction Algorithm

FindIntersection(strArr) read the array of strings stored in strArrwhich will contain 2 elements: the first element will represent a list of comma-separated numbers sorted in ascending order, the second element will represent a second list of comma-separated numbers (also sorted). Your goal is to return a comma-separated string containing the numbers that occur in elements of strArr in sorted order. If there is no intersection, return the string false

Demo 1

Continue reading

TypeScript Syntax

Type Aliases, Union Types, Literal Types, Index Signature

You can find different usages of Type Aliases in the following demo code.

Type Aliases is defined with type word.

Union Types is defined with the | character to separate the different possible types.

Literal Types can be string, number or boolean

type SelectedEvent = "Click"; // string literal type

const buttonEvent: SelectedEvent = "Click";
type Color = "Red" | "Green" | "Blue"; // string literal type with union type

const buttonForeColor: Color = "Red";
type num = 1 | 3 | 5 | 7 | 9; // number literal type with union type
type bool = true | false; // boolean literal type with union type

type TRUE = true;

type FALSE = false;

Index Signature is defined as below

type Dictionary = {
    [index: string]: any;
};

const person: Dictionary = {
    "firstName": "Kenan",
    "lastName": "Hancer",
    "age": 36
};
interface StringArray {
    [index: number]: string;
}

const names: StringArray = ["Bob", "Fred"];

let name1: string = names[0];

Type Aliases can be used with Union Types and Literal Types as below

type obj = {success: true} | {success: false}; // object
type Result<T> = { success: true, value: T } | { success: false, error: string | number }; // object
type PersonCommonFields = { firstName: string, lastName: string };
type Person = PersonCommonFields & { isDeleted: true | false };
type Name = string; // simple type
type NameResolver = () => string; // function
type NameOrResolver = Name | NameResolver;

Demo1

Continue reading

JavaScript Object.assign(), Object.create()

Object.create()

The Object.create() method creates a new object, using an existing object

Demo1

Continue reading

JavaScript Object.entries(), Object.values(), Map, Set Usage

Demo1

Continue reading

Node.js Axios Usage

How to install Java with Jabba

Runtime version managers make developers life easier. So, I tested different Java version managers. But, Jabba is the easiest one for me.

You can read previously posted How to install java articles.

Installing Jabba

Click Jabba link to see more detailed information about Jabba

$ curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh

Make sure to source jabba.sh in your environment if you skip it:

$ [ -s "$JABBA_HOME/jabba.sh" ] && source "$JABBA_HOME/jabba.sh"

If you don't have JAVA_HOME environment variable, run the following code:

$ echo 'export JAVA_HOME=$HOME/.jabba/jdk/openjdk@1.14.0-1/Contents/Home' >> ~/.bash_profile
$ echo 'export JAVA_HOME=$HOME/.jabba/jdk/openjdk@1.14.0-1/Contents/Home' >> ~/.bashrc
$ echo 'export JAVA_HOME=$HOME/.jabba/jdk/openjdk@1.14.0-1/Contents/Home' >> ~/.zshrc
Continue reading