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
lst = [] | |
primeNumberList = [] | |
# input from user | |
lst = [int(item) for item in input("Enter the list items : ").split(",")] | |
# check prime number | |
def prime(n): | |
if n <= 0: |
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
class Department { | |
// private readonly id: string; | |
// private name: string; | |
private employees: string[] = []; | |
constructor(private readonly id: string, public name: string) { | |
// this.id = id; | |
// this.name = n; | |
} | |
} |
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
class Department { | |
private id: string; | |
private name: string; | |
private employees: string[] = []; | |
constructor(id: string, n: string) { | |
this.id = id; | |
this.name = n; | |
} | |
//... |
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
class Department { | |
name: string; | |
employees: string[] = []; | |
constructor(n: string) { | |
this.name = n; | |
} | |
addEmployee(employee: string) { | |
// + validation here (etc.) |
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
class Department { | |
name: string; | |
constructor(n: string) { | |
this.name = n; | |
} | |
describe(this: Department) { | |
console.log('Department: ' + this.name); | |
} |
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
const hobbiesArr = ['Sport', 'Cooking']; | |
// const hobby1 = hobbiesArr[0]; | |
// const hobby2 = hobbiesArr[1]; | |
const [hobby1, hobby2, ...remainingHobbies] = hobbiesArr; // doesn't mutate your original array | |
const personObj = { | |
firstName: 'Max', | |
ageNum: 30, |
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
// const add = (...numbers: number[number, number, number]) => { | |
const addNumber = (...numbers: number[]) => { | |
return numbers.reduce((acc, num) => acc + num, 0); | |
}; | |
const addedNumbers = addNumber(1, 3, 10, 5.5, 3.7); | |
console.log(addedNumbers); |
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
const hobbies = ['Sports', 'Cooking']; | |
const activeHobbies = ['Hiking']; | |
activeHobbies.push(...hobbies); | |
// const activeHobbies = ['Hiking', ...hobbies]; | |
const person = { | |
name: 'Max', | |
age: 30, | |
}; |
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
// default value added | |
const add = (a: number, b: number = 1) => a + b; | |
const printOutputFunc: (a: number | string) => void = (output) => | |
console.log(output); | |
printOutputFunc(add(5)); |
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
const printOutput: (a: number | string) => void = (output) => | |
console.log(output); | |
const button = document.querySelector('button'); | |
if (button) { | |
button.addEventListener('click', (event) => console.log(event)); | |
} |
NewerOlder