This file contains 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
// Input [10, 15, 3, 7], Target : 17 | |
// if yes then return true else false. | |
// Brute force way. | |
//Solution 1: | |
function sumOfTwoNum(arr,target){ | |
for(let i = 0 ; i < arr.length; i ++){ | |
for(let j = 0; j < arr.length; j++){ |
This file contains 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 sumOfTwoNum(array,target){ | |
let storeMap = {}; | |
for(let arr of array){ | |
if(storeMap[arr]){ | |
return true; | |
} | |
storeMap[target - arr] = arr; | |
} |
This file contains 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 { TestBed, async } from '@angular/core/testing'; | |
import { AppComponent } from './app.component'; | |
describe('App component', () => { | |
beforeEach(async(() => { | |
// The TestBed is the most important of the Angular testing utilities. | |
// The TestBed creates a dynamically-constructed Angular test module that emulates an Angular @NgModule. | |
// The TestBed.configureTestingModule() method takes a metadata object that can have most of the properties of an @NgModule. | |
TestBed.configureTestingModule({ | |
declarations: [AppComponent] |
This file contains 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 { TestBed, async } from '@angular/core/testing'; | |
import { AppComponent } from './app.component'; | |
import { UserComponent } from './user/user.component'; | |
import { UserAsyncComponent } from './user-async/user-async.component'; | |
describe('App component', () => { | |
beforeEach(async(() => { | |
// The TestBed is the most important of the Angular testing utilities. | |
// The TestBed creates a dynamically-constructed Angular test module that emulates an Angular @NgModule. |
This file contains 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
<!--The content below is only a placeholder and can be replaced.--> | |
<div style="text-align:center"> | |
<h1> | |
Welcome to {{ title }}! | |
</h1> | |
<app-user></app-user> | |
<br> | |
<app-user-async></app-user-async> | |
</div> |
This file contains 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'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'] | |
}) | |
export class AppComponent implements OnInit { | |
title = 'Angular7-unit-testing!'; |
This file contains 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 { TestBed, async } from '@angular/core/testing'; | |
import { AppComponent } from './app.component'; | |
import { UserComponent } from './user/user.component'; | |
import { UserAsyncComponent } from './user-async/user-async.component'; | |
describe('App component', () => { | |
beforeEach(async(() => { | |
// The TestBed is the most important of the Angular testing utilities. | |
// The TestBed creates a dynamically-constructed Angular test module that emulates an Angular @NgModule. | |
// The TestBed.configureTestingModule() method takes a metadata object that can have most of the properties of an @NgModule. |
This file contains 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
<div *ngIf="isUserLoggedIn"> | |
<p> | |
Welcome {{user.name}} | |
</p> | |
</div> | |
<div *ngIf="!isUserLoggedIn"> | |
<p> | |
user is NOT logged In. | |
</p> | |
</div> |
This file contains 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 { UserService } from './user.service'; | |
@Component({ | |
selector: 'app-user', | |
templateUrl: './user.component.html', | |
styleUrls: ['./user.component.scss'], | |
providers: [UserService] | |
}) | |
export class UserComponent implements OnInit { |
This file contains 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 { Injectable } from '@angular/core'; | |
@Injectable() | |
export class UserService { | |
user = { | |
name: 'Mannie' | |
}; | |
getUser() { | |
return this.user; |
OlderNewer