-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlecture-7.js
More file actions
74 lines (53 loc) · 1.51 KB
/
lecture-7.js
File metadata and controls
74 lines (53 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import userData from './users.constant.js';
// 3,5
// 3,6,9,12,15
function printTable(tableNumber, end) {
if (typeof tableNumber !== 'number' || typeof end != 'number') {
return `Enter valid number`;
}
for (let i = 1; i <= end; i++) {
console.log(i * tableNumber);
}
}
printTable(2, 10);
let arrData = ['are you Okay', 'i am good'];
function getAllVowelsAsArray(arr) {
if (!Array.isArray(arr)) {
return `Enter valid array only`
}
if (arr.every(element => typeof element !== 'string')) {
return 'Enter string array only!';
}
const vowels = 'aeiouAEIOU';
let result = [];
for (let str of arr) {
for (let char of str) {
if (vowels.includes(char)) {
result.push(char);
}
}
}
return result;
}
console.log(getAllVowelsAsArray(arrData));
let strData = 'hElloWorld!';
function getAllVowelsAsString(strInput) {
if (typeof strInput !== 'string') {
return `Enter valid string only!`;
}
const vowels = 'aeiouAEIOU';
let result = '';
for (let i = 0; i < strInput.length; i++) {
if (vowels.includes(strInput[i])) {
result += strInput[i];
}
}
return result;
}
console.log(getAllVowelsAsString(strData));
function getFilteredUsers(userDataList){
return userDataList.filter(element =>
element.skills.includes('TypeScript')
)
}
console.log(getFilteredUsers(userData));