Skip to content

Commit

Permalink
Mid-day push of demo files
Browse files Browse the repository at this point in the history
  • Loading branch information
mattry committed Dec 12, 2024
1 parent 4c1f183 commit aed60f9
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
2 changes: 2 additions & 0 deletions week1/day4/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var message = "Hello, TypeScript";
console.log(message);
2 changes: 2 additions & 0 deletions week1/day4/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let message: string = "Hello, TypeScript";
console.log(message);
40 changes: 40 additions & 0 deletions week1/day4/practice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var message = "Hello, World";
function printChars(s) {
for (var i = 0; i < s.length; i++) {
console.log(s[i]);
}
}
function printVowels(s) {
var vowels;
(function (vowels) {
vowels[vowels["a"] = 0] = "a";
vowels[vowels["e"] = 1] = "e";
vowels[vowels["i"] = 2] = "i";
vowels[vowels["o"] = 3] = "o";
vowels[vowels["u"] = 4] = "u";
})(vowels || (vowels = {}));
;
for (var i = 0; i < s.length; i++) {
if (s[i] in vowels) {
console.log(s[i]);
}
}
}
function getProduct() {
var nums = [];
for (var _i = 0; _i < arguments.length; _i++) {
nums[_i] = arguments[_i];
}
var total = 1;
nums.forEach(function (num) {
total *= num;
});
return total;
}
console.log(getProduct(2, 2));
console.log(getProduct(2, 4));
console.log(getProduct(3, 3, 3, 3, 3));
console.log("Characters in Message: ");
printChars(message);
console.log("Vowels in Message: ");
printVowels(message);
43 changes: 43 additions & 0 deletions week1/day4/practice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
let message: string = "Hello, World";

function printChars(s: string): void {
for (let i = 0; i < s.length; i++) {
console.log(s[i]);
}
}

function printVowels(s: string): void {
enum vowels {
'a',
'e',
'i',
'o',
'u',
};

for (let i = 0; i < s.length; i++) {
if (s[i] in vowels) {
console.log(s[i]);
}
}
}

function getProduct(...nums: number[]): number {
let total: number = 1;

nums.forEach(num => {
total *= num;
});

return total;
}

console.log(getProduct(2, 2));
console.log(getProduct(2, 4));
console.log(getProduct(3,3,3,3,3));

console.log("Characters in Message: ");
printChars(message);

console.log("Vowels in Message: ");
printVowels(message);

0 comments on commit aed60f9

Please sign in to comment.