diff --git a/week1/day4/hello.js b/week1/day4/hello.js new file mode 100644 index 0000000..5e0e132 --- /dev/null +++ b/week1/day4/hello.js @@ -0,0 +1,2 @@ +var message = "Hello, TypeScript"; +console.log(message); diff --git a/week1/day4/hello.ts b/week1/day4/hello.ts new file mode 100644 index 0000000..e3bc7d7 --- /dev/null +++ b/week1/day4/hello.ts @@ -0,0 +1,2 @@ +let message: string = "Hello, TypeScript"; +console.log(message); \ No newline at end of file diff --git a/week1/day4/practice.js b/week1/day4/practice.js new file mode 100644 index 0000000..0730fa5 --- /dev/null +++ b/week1/day4/practice.js @@ -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); diff --git a/week1/day4/practice.ts b/week1/day4/practice.ts new file mode 100644 index 0000000..b1b4a15 --- /dev/null +++ b/week1/day4/practice.ts @@ -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); \ No newline at end of file