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
| // length property tells how many elements are inside the array | |
| let fruits = ["apple", "banana", "orange"]; | |
| console.log(fruits.length); | |
| // push() method: adds a new element to the end of the array | |
| fruits = ["apple", "banana"]; | |
| fruits.push("orange"); | |
| console.log(fruits.length); | |
| // pop() method: removes the last element from the array |
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 class BaseContract { | |
| contractId: string; | |
| clientName: string; | |
| isActive: boolean; | |
| constructor(contractId: string, clientName: string, isActive: boolean) { | |
| this.contractId = contractId; | |
| this.clientName = clientName; | |
| this.isActive = isActive; | |
| } |
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 { User } from '../src/user'; | |
| test("should be able to give consent",() => { | |
| const user = new User( "Will", "Doe", 19); | |
| user.giveConsent(); | |
| expect(user.getConsent()).toBeTruthy(); | |
| }) | |
| test("should not be able to give consent",() => { | |
| const user = new User( "Jane", "Doe", 18); |
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 { HomeWork } from '../src/homework' | |
| import { multiplication, calculatePercentage, isEven, stringComparison, isPositive } from '../src/homework' | |
| describe('HomeWork Class testing', () => { | |
| let operation: HomeWork; | |
| test('should multiply two numbers correctly', () => { | |
| operation = new HomeWork(); | |
| expect(operation.multiplication(2, 3)).toBe(6); | |
| }) |
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
| //Assignment #1 | |
| class Calculator { | |
| // for static methods no need to create a new instance | |
| static additionReturnNumber(num1: number, num2: number): number { | |
| return num1 + num2; | |
| } | |
| static additionReturnString(num1: number, num2: number): string { | |
| const resultNum: number = num1 + num2; |
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
| //Assignment #2 | |
| //Task1 | |
| //Create class | |
| class Person { | |
| firstName: string; | |
| lastName: string; | |
| } | |
| //Create instance 1 | |
| const person1 = new Person(); |
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
| //Assignment #2 | |
| //Task1 | |
| //Create class | |
| class Person { | |
| firstName: string; | |
| lastName: string; | |
| } | |
| //Create instance 1 | |
| const person1 = new Person(); |
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
| //Assignment #1 | |
| function convertToFahrenheit (celsius: number):number { | |
| return (celsius * 9 / 5) + 32; | |
| } | |
| function greetUser (firstName: string, lastName: string): string { | |
| return ("Hello, " + firstName + " " + lastName + "!"); | |
| } | |
| function calculateArea (width: number, height: number): number { |