This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.range = function(start, stop) { | |
let d = []; | |
for (let i = start; i <= stop; i++) { | |
d.push(i); | |
} | |
return d; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = "How good is have account on StackOverflow and create new posts" | |
def odd(data): | |
idx, el = data | |
return el if idx % 2 == 0 else el + "\n" | |
print(" ".join(list(map(odd, list(enumerate(string.split(" "))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { async, TestBed } from '@angular/core/testing'; | |
import { Observable, of } from 'rxjs'; | |
import { AppComponent } from './app.component'; | |
import { HerbsService } from './herbs.service'; | |
import { RouterTestingModule } from '@angular/router/testing'; | |
class MockService { | |
mockRespone = { | |
data: [ | |
{ id: 1, name: 'hello' }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Knight { | |
constructor(private name: string, private age: number) { } | |
public getAge(): number { | |
return this.age; | |
} | |
public getName(): string { | |
return this.name; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Beverage { | |
description: string = "unknown beverage"; | |
public getDescription(): string { | |
return this.description; | |
} | |
public abstract cost(): number; | |
} | |
abstract class CondimentDecorator extends Beverage { | |
abstract getDescription(): string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { from } from "rxjs"; | |
import { filter, reduce } from "rxjs/operators"; | |
let candidates = [ | |
{ name: 'Brendan Eich', experience: 'JavaScript Inventor' }, | |
{ name: 'Emmet Brown', experience: 'Historian' }, | |
{ name: 'George Lucas', experience: 'Sci-fi writer' }, | |
{ name: 'Alberto Perez', experience: 'Zumba Instructor' }, | |
{ name: 'Bjarne Stroustrup', experience: 'C++ Developer' } | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type HTMLElementEvent<T extends HTMLElement> = Event & { | |
target: T; | |
} | |
let res = allEvents$.subscribe((item: HTMLElementEvent<HTMLButtonElement>) => { | |
console.log(item.target.value); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I think, that this is an interesting answer. Check if object key exists, if yes, double | |
const columns = [ | |
{ name: 'one', title: 'Order Number', id: 1 }, | |
{ name: 'two', title: 'Strawberry', id: 2 }, | |
{ name: 'three', title: 'Vanilla', id: 3 } | |
]; | |
const mapped = columns.map( | |
item => item.id ? item.id = item.id * 2 : item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// So, you have input data like this | |
let objArr = [ | |
{ id: 1, name: 'Kamil' }, | |
{ id: 2, name: 'Janusz' }, | |
{ id: 3, name: 'Mariusz' }, | |
{ id: 4, name: 'Alina' }, | |
{ id: 5, name: 'Olo' } ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// so, you have list of users like this | |
const users = [ | |
{ id: '1', name: 'hello' }, | |
{ id: '2', name: 'world' }, | |
{ id: '3', name: 'hello' }, | |
{ id: '1', name: 'hello' }, | |
{ id: '1', name: 'hello' }, | |
] |