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
| setTimeout(() => { | |
| console.log('Hello timeout!'); | |
| }, 1000); //will print "Hello timeout!" once, after 1 second | |
| setInterval(() => { | |
| console.log('Hello interval!'); | |
| }, 1000) //will print "Hello interval!" every 1 second |
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
| console.log('Start'); | |
| setTimeout(() => { | |
| console.log('Hello timeout!'); | |
| }, 0); | |
| console.log('End'); |
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
| setTimeout(function run() { | |
| console.log('Hello!'); | |
| setTimeout(run, 1000); | |
| }, 1000); |
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 insertionSort(array) { | |
| let i = 1; | |
| let x; | |
| while (i < array.length) { | |
| x = array[i] | |
| let j = i - 1; | |
| while (j >= 0 && array[j] > x) { | |
| array[j + 1] = array[j]; | |
| j = j - 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 merge(left, right) { | |
| const result = []; | |
| while (left.length > 0 && right.length > 0) { | |
| if (left[0] <= right[0]) { | |
| result.push(left[0]); | |
| left = left.slice(1); | |
| } else { | |
| result.push(right[0]); | |
| right = right.slice(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 quickSort(array, low, high) { | |
| if (low < high) { | |
| const p = partition(array, low, high); | |
| quickSort(array, low, p); | |
| quickSort(array, p + 1, high); | |
| } | |
| } | |
| function partition(array, low, high) { | |
| const middleIndex = Math.floor((high + low) / 2); |
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 bubbleSort(array) { | |
| let swapped = true; | |
| while (swapped) { | |
| swapped = false; | |
| for (let i = 1; i < array.length; i += 1) { | |
| if (array[i - 1] > array[i]) { | |
| swapped = true; | |
| const temp = array[i]; | |
| array[i] = array[i - 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
| export default interface Dog { | |
| name: string; | |
| age: number; | |
| favoritePark: string; | |
| profilePicture?: 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 { Injectable } from '@angular/core'; | |
| import Dog from '../models/Dog'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class MembersService { | |
| get members(): Dog[] { | |
| return [ | |
| { |
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
| <h2>List of Members:</h2> | |
| <app-dog-item *ngFor="let member of members" [member]="member"></app-dog-item> |