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
| function questionsMarks(string) { | |
| let number = pair = count = 0 | |
| for (let char of string) { | |
| if ( !isNaN(char) ) { | |
| if (number && number + +char === 10) { | |
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
| function vowelSquare(matrix) { | |
| let vowels = { | |
| a: 1, | |
| e: 1, | |
| i: 1, | |
| o: 1, | |
| u: 1 | |
| } | |
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
| function scaleBalancing(plates, weights) { | |
| weights.sort((a, b) => a - b) | |
| let [a, b] = plates | |
| if (a === b) { | |
| return 'already balanced' | |
| } |
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
| function isValid(string) { | |
| let v = 0 | |
| let h = 0 | |
| for (let char of string) { | |
| if (char === 'd') v++ | |
| if (char === 'u') v-- | |
| if (char === 'r') h++ |
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
| function closestEnemy(matrix) { | |
| let length = matrix.length | |
| let isValid = matrix.some(v => v.includes(2)) | |
| if (!isValid) return -1 | |
| let startingPoint | |
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 { HttpClientModule } from '@angular/common/http' | |
| import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api' | |
| import { MyInMemoryService } from './services/my-in-memory.service' | |
| @NgModule({ | |
| imports: [ | |
| HttpClientModule, | |
| // import HttpClientInMemoryWebApiModule after HttpClientModule | |
| HttpClientInMemoryWebApiModule.forRoot(MyInMemoryService) | |
| ] |
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 { InMemoryDbService } from 'angular-in-memory-web-api'; | |
| import { RequestInfo } from 'angular-in-memory-web-api/interfaces'; | |
| export class MyInMemoryService implements InMemoryDbService { | |
| // In-Memory DB will intercept /api/whatever calls and return data | |
| createDb() { | |
| const customers = [ | |
| { id: 1, username: 'fred92', password: '1234' }, | |
| { id: 2, username: 'john69', password: 'abcd' }, |
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
| @Injectable() | |
| export class CustomersService { | |
| constructor( | |
| private http: Http) { } | |
| getAll() { | |
| return this.http.get('api/customers') | |
| .subscribe(customers => { | |
| console.log(customers) |
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 { InMemoryDbService } from 'angular-in-memory-web-api' | |
| import { RequestInfo } from 'angular-in-memory-web-api/interfaces' | |
| export class MyInMemoryService implements InMemoryDbService { | |
| createDb() { | |
| // same as before | |
| } | |
| // HTTP POST interceptor |
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 { Component, OnInit } from '@angular/core' | |
| import { Router } from '@angular/router' | |
| import { tap, catchError } from 'rxjs/operators' | |
| import { throwError } from 'rxjs' | |
| @Component({ | |
| selector: 'app-login', | |
| templateUrl: './login.component.html', | |
| styleUrls: ['./login.component.css'] | |
| }) |
OlderNewer