├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── LICENSE-CODE ├── README.md ├── SECURITY.md └── code ├── module-01 └── m01-end │ ├── build │ └── module01.js │ ├── module01.html │ ├── module01.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── module-02 ├── m02-end │ ├── build │ │ └── module02.js │ ├── module02.html │ ├── module02.ts │ ├── tsconfig.json │ └── workspace.code-workspace └── m02-start │ ├── build │ └── module02.js │ ├── module02.html │ ├── module02.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── module-03 ├── m03-end │ ├── build │ │ └── module03.js │ ├── module03.html │ ├── module03.ts │ ├── tsconfig.json │ └── workspace.code-workspace └── m03-start │ ├── build │ └── module03.js │ ├── module03.html │ ├── module03.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── module-04 ├── m04-end │ ├── build │ │ └── module04.js │ ├── module04.html │ ├── module04.ts │ ├── tsconfig.json │ └── workspace.code-workspace └── m04-start │ ├── build │ └── module04.js │ ├── module04.html │ ├── module04.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── module-05 ├── m05-end │ ├── build │ │ └── module05.js │ ├── module05.html │ ├── module05.ts │ ├── tsconfig.json │ └── workspace.code-workspace └── m05-start │ ├── build │ └── module05.js │ ├── module05.html │ ├── module05.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── module-06 ├── m06-end │ ├── build │ │ └── module06.js │ ├── module06.html │ ├── module06.ts │ ├── tsconfig.json │ └── workspace.code-workspace └── m06-start │ ├── build │ └── module06.js │ ├── module06.html │ ├── module06.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── module-07 ├── m07-end │ ├── module07.html │ ├── module07_loan-programs.js │ ├── module07_loan-programs.ts │ ├── module07_loans.js │ ├── module07_loans.ts │ ├── module07_main.js │ ├── module07_main.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── m07-start │ ├── module07.html │ ├── module07_loan-programs.ts │ ├── module07_loans.ts │ ├── module07_main.ts │ ├── tsconfig.json │ └── workspace.code-workspace ├── module07-exercise-01-end │ ├── greetings-utilities_module.js │ ├── greetings-utilities_module.ts │ ├── greetings_module.js │ ├── greetings_module.ts │ ├── main.js │ ├── main.ts │ ├── module07-exercise.ts │ ├── tsconfig.json │ └── workspace.code-workspace └── module07-exercise-02-end │ ├── main.js │ ├── main.ts │ ├── package-lock.json │ └── tsconfig.json ├── module-08 ├── m08-end │ ├── module08.html │ ├── module08_loan-programs.ts │ ├── module08_loans.ts │ ├── module08_main.ts │ ├── readme.md │ ├── tsconfig.json │ └── workspace.code-workspace └── m08-start │ ├── build │ └── module08_main.js │ ├── module08.html │ ├── module08_main.ts │ ├── tsconfig.json │ └── workspace.code-workspace └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More_considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution 4.0 International Public License 58 | 59 | By exercising the Licensed Rights (defined below), You accept and agree 60 | to be bound by the terms and conditions of this Creative Commons 61 | Attribution 4.0 International Public License ("Public License"). To the 62 | extent this Public License may be interpreted as a contract, You are 63 | granted the Licensed Rights in consideration of Your acceptance of 64 | these terms and conditions, and the Licensor grants You such rights in 65 | consideration of benefits the Licensor receives from making the 66 | Licensed Material available under these terms and conditions. 67 | 68 | 69 | Section 1 -- Definitions. 70 | 71 | a. Adapted Material means material subject to Copyright and Similar 72 | Rights that is derived from or based upon the Licensed Material 73 | and in which the Licensed Material is translated, altered, 74 | arranged, transformed, or otherwise modified in a manner requiring 75 | permission under the Copyright and Similar Rights held by the 76 | Licensor. For purposes of this Public License, where the Licensed 77 | Material is a musical work, performance, or sound recording, 78 | Adapted Material is always produced where the Licensed Material is 79 | synched in timed relation with a moving image. 80 | 81 | b. Adapter's License means the license You apply to Your Copyright 82 | and Similar Rights in Your contributions to Adapted Material in 83 | accordance with the terms and conditions of this Public License. 84 | 85 | c. Copyright and Similar Rights means copyright and/or similar rights 86 | closely related to copyright including, without limitation, 87 | performance, broadcast, sound recording, and Sui Generis Database 88 | Rights, without regard to how the rights are labeled or 89 | categorized. For purposes of this Public License, the rights 90 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 91 | Rights. 92 | 93 | d. Effective Technological Measures means those measures that, in the 94 | absence of proper authority, may not be circumvented under laws 95 | fulfilling obligations under Article 11 of the WIPO Copyright 96 | Treaty adopted on December 20, 1996, and/or similar international 97 | agreements. 98 | 99 | e. Exceptions and Limitations means fair use, fair dealing, and/or 100 | any other exception or limitation to Copyright and Similar Rights 101 | that applies to Your use of the Licensed Material. 102 | 103 | f. Licensed Material means the artistic or literary work, database, 104 | or other material to which the Licensor applied this Public 105 | License. 106 | 107 | g. Licensed Rights means the rights granted to You subject to the 108 | terms and conditions of this Public License, which are limited to 109 | all Copyright and Similar Rights that apply to Your use of the 110 | Licensed Material and that the Licensor has authority to license. 111 | 112 | h. Licensor means the individual(s) or entity(ies) granting rights 113 | under this Public License. 114 | 115 | i. Share means to provide material to the public by any means or 116 | process that requires permission under the Licensed Rights, such 117 | as reproduction, public display, public performance, distribution, 118 | dissemination, communication, or importation, and to make material 119 | available to the public including in ways that members of the 120 | public may access the material from a place and at a time 121 | individually chosen by them. 122 | 123 | j. Sui Generis Database Rights means rights other than copyright 124 | resulting from Directive 96/9/EC of the European Parliament and of 125 | the Council of 11 March 1996 on the legal protection of databases, 126 | as amended and/or succeeded, as well as other essentially 127 | equivalent rights anywhere in the world. 128 | 129 | k. You means the individual or entity exercising the Licensed Rights 130 | under this Public License. Your has a corresponding meaning. 131 | 132 | 133 | Section 2 -- Scope. 134 | 135 | a. License grant. 136 | 137 | 1. Subject to the terms and conditions of this Public License, 138 | the Licensor hereby grants You a worldwide, royalty-free, 139 | non-sublicensable, non-exclusive, irrevocable license to 140 | exercise the Licensed Rights in the Licensed Material to: 141 | 142 | a. reproduce and Share the Licensed Material, in whole or 143 | in part; and 144 | 145 | b. produce, reproduce, and Share Adapted Material. 146 | 147 | 2. Exceptions and Limitations. For the avoidance of doubt, where 148 | Exceptions and Limitations apply to Your use, this Public 149 | License does not apply, and You do not need to comply with 150 | its terms and conditions. 151 | 152 | 3. Term. The term of this Public License is specified in Section 153 | 6(a). 154 | 155 | 4. Media and formats; technical modifications allowed. The 156 | Licensor authorizes You to exercise the Licensed Rights in 157 | all media and formats whether now known or hereafter created, 158 | and to make technical modifications necessary to do so. The 159 | Licensor waives and/or agrees not to assert any right or 160 | authority to forbid You from making technical modifications 161 | necessary to exercise the Licensed Rights, including 162 | technical modifications necessary to circumvent Effective 163 | Technological Measures. For purposes of this Public License, 164 | simply making modifications authorized by this Section 2(a) 165 | (4) never produces Adapted Material. 166 | 167 | 5. Downstream recipients. 168 | 169 | a. Offer from the Licensor -- Licensed Material. Every 170 | recipient of the Licensed Material automatically 171 | receives an offer from the Licensor to exercise the 172 | Licensed Rights under the terms and conditions of this 173 | Public License. 174 | 175 | b. No downstream restrictions. You may not offer or impose 176 | any additional or different terms or conditions on, or 177 | apply any Effective Technological Measures to, the 178 | Licensed Material if doing so restricts exercise of the 179 | Licensed Rights by any recipient of the Licensed 180 | Material. 181 | 182 | 6. No endorsement. Nothing in this Public License constitutes or 183 | may be construed as permission to assert or imply that You 184 | are, or that Your use of the Licensed Material is, connected 185 | with, or sponsored, endorsed, or granted official status by, 186 | the Licensor or others designated to receive attribution as 187 | provided in Section 3(a)(1)(A)(i). 188 | 189 | b. Other rights. 190 | 191 | 1. Moral rights, such as the right of integrity, are not 192 | licensed under this Public License, nor are publicity, 193 | privacy, and/or other similar personality rights; however, to 194 | the extent possible, the Licensor waives and/or agrees not to 195 | assert any such rights held by the Licensor to the limited 196 | extent necessary to allow You to exercise the Licensed 197 | Rights, but not otherwise. 198 | 199 | 2. Patent and trademark rights are not licensed under this 200 | Public License. 201 | 202 | 3. To the extent possible, the Licensor waives any right to 203 | collect royalties from You for the exercise of the Licensed 204 | Rights, whether directly or through a collecting society 205 | under any voluntary or waivable statutory or compulsory 206 | licensing scheme. In all other cases the Licensor expressly 207 | reserves any right to collect such royalties. 208 | 209 | 210 | Section 3 -- License Conditions. 211 | 212 | Your exercise of the Licensed Rights is expressly made subject to the 213 | following conditions. 214 | 215 | a. Attribution. 216 | 217 | 1. If You Share the Licensed Material (including in modified 218 | form), You must: 219 | 220 | a. retain the following if it is supplied by the Licensor 221 | with the Licensed Material: 222 | 223 | i. identification of the creator(s) of the Licensed 224 | Material and any others designated to receive 225 | attribution, in any reasonable manner requested by 226 | the Licensor (including by pseudonym if 227 | designated); 228 | 229 | ii. a copyright notice; 230 | 231 | iii. a notice that refers to this Public License; 232 | 233 | iv. a notice that refers to the disclaimer of 234 | warranties; 235 | 236 | v. a URI or hyperlink to the Licensed Material to the 237 | extent reasonably practicable; 238 | 239 | b. indicate if You modified the Licensed Material and 240 | retain an indication of any previous modifications; and 241 | 242 | c. indicate the Licensed Material is licensed under this 243 | Public License, and include the text of, or the URI or 244 | hyperlink to, this Public License. 245 | 246 | 2. You may satisfy the conditions in Section 3(a)(1) in any 247 | reasonable manner based on the medium, means, and context in 248 | which You Share the Licensed Material. For example, it may be 249 | reasonable to satisfy the conditions by providing a URI or 250 | hyperlink to a resource that includes the required 251 | information. 252 | 253 | 3. If requested by the Licensor, You must remove any of the 254 | information required by Section 3(a)(1)(A) to the extent 255 | reasonably practicable. 256 | 257 | 4. If You Share Adapted Material You produce, the Adapter's 258 | License You apply must not prevent recipients of the Adapted 259 | Material from complying with this Public License. 260 | 261 | 262 | Section 4 -- Sui Generis Database Rights. 263 | 264 | Where the Licensed Rights include Sui Generis Database Rights that 265 | apply to Your use of the Licensed Material: 266 | 267 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 268 | to extract, reuse, reproduce, and Share all or a substantial 269 | portion of the contents of the database; 270 | 271 | b. if You include all or a substantial portion of the database 272 | contents in a database in which You have Sui Generis Database 273 | Rights, then the database in which You have Sui Generis Database 274 | Rights (but not its individual contents) is Adapted Material; and 275 | 276 | c. You must comply with the conditions in Section 3(a) if You Share 277 | all or a substantial portion of the contents of the database. 278 | 279 | For the avoidance of doubt, this Section 4 supplements and does not 280 | replace Your obligations under this Public License where the Licensed 281 | Rights include other Copyright and Similar Rights. 282 | 283 | 284 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 285 | 286 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 287 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 288 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 289 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 290 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 291 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 292 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 293 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 294 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 295 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 296 | 297 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 298 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 299 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 300 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 301 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 302 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 303 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 304 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 305 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 306 | 307 | c. The disclaimer of warranties and limitation of liability provided 308 | above shall be interpreted in a manner that, to the extent 309 | possible, most closely approximates an absolute disclaimer and 310 | waiver of all liability. 311 | 312 | 313 | Section 6 -- Term and Termination. 314 | 315 | a. This Public License applies for the term of the Copyright and 316 | Similar Rights licensed here. However, if You fail to comply with 317 | this Public License, then Your rights under this Public License 318 | terminate automatically. 319 | 320 | b. Where Your right to use the Licensed Material has terminated under 321 | Section 6(a), it reinstates: 322 | 323 | 1. automatically as of the date the violation is cured, provided 324 | it is cured within 30 days of Your discovery of the 325 | violation; or 326 | 327 | 2. upon express reinstatement by the Licensor. 328 | 329 | For the avoidance of doubt, this Section 6(b) does not affect any 330 | right the Licensor may have to seek remedies for Your violations 331 | of this Public License. 332 | 333 | c. For the avoidance of doubt, the Licensor may also offer the 334 | Licensed Material under separate terms or conditions or stop 335 | distributing the Licensed Material at any time; however, doing so 336 | will not terminate this Public License. 337 | 338 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 339 | License. 340 | 341 | 342 | Section 7 -- Other Terms and Conditions. 343 | 344 | a. The Licensor shall not be bound by any additional or different 345 | terms or conditions communicated by You unless expressly agreed. 346 | 347 | b. Any arrangements, understandings, or agreements regarding the 348 | Licensed Material not stated herein are separate from and 349 | independent of the terms and conditions of this Public License. 350 | 351 | 352 | Section 8 -- Interpretation. 353 | 354 | a. For the avoidance of doubt, this Public License does not, and 355 | shall not be interpreted to, reduce, limit, restrict, or impose 356 | conditions on any use of the Licensed Material that could lawfully 357 | be made without permission under this Public License. 358 | 359 | b. To the extent possible, if any provision of this Public License is 360 | deemed unenforceable, it shall be automatically reformed to the 361 | minimum extent necessary to make it enforceable. If the provision 362 | cannot be reformed, it shall be severed from this Public License 363 | without affecting the enforceability of the remaining terms and 364 | conditions. 365 | 366 | c. No term or condition of this Public License will be waived and no 367 | failure to comply consented to unless expressly agreed to by the 368 | Licensor. 369 | 370 | d. Nothing in this Public License constitutes or may be interpreted 371 | as a limitation upon, or waiver of, any privileges and immunities 372 | that apply to the Licensor or You, including from the legal 373 | processes of any jurisdiction or authority. 374 | 375 | 376 | ======================================================================= 377 | 378 | Creative Commons is not a party to its public 379 | licenses. Notwithstanding, Creative Commons may elect to apply one of 380 | its public licenses to material it publishes and in those instances 381 | will be considered the “Licensor.” The text of the Creative Commons 382 | public licenses is dedicated to the public domain under the CC0 Public 383 | Domain Dedication. Except for the limited purpose of indicating that 384 | material is shared under a Creative Commons public license or as 385 | otherwise permitted by the Creative Commons policies published at 386 | creativecommons.org/policies, Creative Commons does not authorize the 387 | use of the trademark "Creative Commons" or any other trademark or logo 388 | of Creative Commons without its prior written consent including, 389 | without limitation, in connection with any unauthorized modifications 390 | to any of its public licenses or any other arrangements, 391 | understandings, or agreements concerning use of licensed material. For 392 | the avoidance of doubt, this paragraph does not form part of the 393 | public licenses. 394 | 395 | Creative Commons may be contacted at creativecommons.org. -------------------------------------------------------------------------------- /LICENSE-CODE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributing 3 | 4 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 5 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 6 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. 7 | 8 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide 9 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions 10 | provided by the bot. You will only need to do this once across all repos using our CLA. 11 | 12 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 13 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 14 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 15 | 16 | # Legal Notices 17 | 18 | Microsoft and any contributors grant you a license to the Microsoft documentation and other content 19 | in this repository under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode), 20 | see the [LICENSE](LICENSE) file, and grant you a license to any code in the repository under the [MIT License](https://opensource.org/licenses/MIT), see the 21 | [LICENSE-CODE](LICENSE-CODE) file. 22 | 23 | Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation 24 | may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. 25 | The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. 26 | Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653. 27 | 28 | Privacy information can be found at https://privacy.microsoft.com/en-us/ 29 | 30 | Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents, 31 | or trademarks, whether by implication, estoppel or otherwise. 32 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | -------------------------------------------------------------------------------- /code/module-01/m01-end/build/module01.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function AddNumbers(num1, num2) { 3 | return num1 + num2; 4 | } 5 | console.log(AddNumbers(3, 6)); 6 | -------------------------------------------------------------------------------- /code/module-01/m01-end/module01.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module01.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-01/m01-end/module01.ts: -------------------------------------------------------------------------------- 1 | function AddNumbers(num1: number, num2: number) { 2 | return num1 + num2; 3 | } 4 | console.log(AddNumbers(3, 6)); 5 | -------------------------------------------------------------------------------- /code/module-01/m01-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-01/m01-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-02/m02-end/build/module02.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* Module 2: Declare variable types in TypeScript 3 | Lab End */ 4 | /* EXERCISE 1 5 | TODO: Modify the code to add types to the variable declarations. 6 | The resulting JavaScript should look the same as the original example when you're done. */ 7 | let firstName; 8 | let lastName; 9 | let fullName; 10 | let age; 11 | let ukCitizen; 12 | firstName = 'Rebecca'; 13 | lastName = 'Smith'; 14 | age = 42; 15 | ukCitizen = false; 16 | fullName = firstName + " " + lastName; 17 | if (ukCitizen) { 18 | console.log("My name is " + fullName + ", I'm " + age + ", and I'm a citizen of the United Kingdom."); 19 | } 20 | else { 21 | console.log("My name is " + fullName + ", I'm " + age + ", and I'm not a citizen of the United Kingdom."); 22 | } 23 | /* EXERCISE 2 24 | TODO: You can use types to ensure operation outcomes. Run the code as is and then modify 25 | it to have strongly typed variables. Then, address any errors you find so that the result 26 | returned to a is 12. */ 27 | let x; 28 | let y; 29 | let a; 30 | x = 5; 31 | y = 7; 32 | a = x + y; 33 | console.log(a); 34 | /* EXERCISE 3 35 | TODO: In the following code, implement an enum type called Season that represents 36 | the constants "Fall", "Winter", "Spring", and "Summer". Then, update the function so 37 | you can pass in the season by referencing an item in the enum, for example 38 | Season.Fall, instead of the literal string "Fall". */ 39 | var Season; 40 | (function (Season) { 41 | Season[Season["Winter"] = 0] = "Winter"; 42 | Season[Season["Spring"] = 1] = "Spring"; 43 | Season[Season["Summer"] = 2] = "Summer"; 44 | Season[Season["Fall"] = 3] = "Fall"; 45 | })(Season || (Season = {})); 46 | ; 47 | function whichMonths(season) { 48 | let monthsInSeason; 49 | switch (season) { 50 | case Season.Fall: 51 | monthsInSeason = "September to November"; 52 | break; 53 | case Season.Winter: 54 | monthsInSeason = "December to February"; 55 | break; 56 | case Season.Spring: 57 | monthsInSeason = "March to May"; 58 | break; 59 | case Season.Summer: 60 | monthsInSeason = "June to August"; 61 | } 62 | return monthsInSeason; 63 | } 64 | console.log(whichMonths(Season.Spring)); 65 | /* EXERCISE 4 66 | TODO: Declare the array as the type to match the type of the items in the array. */ 67 | let randomNumbers = []; 68 | let nextNumber; 69 | for (let i = 0; i < 10; i++) { 70 | nextNumber = Math.floor(Math.random() * (100 - 1)) + 1; 71 | randomNumbers.push(nextNumber); 72 | } 73 | console.log(randomNumbers); 74 | -------------------------------------------------------------------------------- /code/module-02/m02-end/module02.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module02.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-02/m02-end/module02.ts: -------------------------------------------------------------------------------- 1 | /* Module 2: Declare variable types in TypeScript 2 | Lab End */ 3 | 4 | /* EXERCISE 1 5 | TODO: Modify the code to add types to the variable declarations. 6 | The resulting JavaScript should look the same as the original example when you're done. */ 7 | 8 | let firstName: string; 9 | let lastName: string; 10 | let fullName: string; 11 | let age: number; 12 | let ukCitizen: boolean; 13 | 14 | firstName = 'Rebecca'; 15 | lastName = 'Smith'; 16 | age = 42; 17 | ukCitizen = false; 18 | fullName = firstName + " " + lastName; 19 | 20 | if (ukCitizen) { 21 | console.log("My name is " + fullName + ", I'm " + age + ", and I'm a citizen of the United Kingdom."); 22 | } else { 23 | console.log("My name is " + fullName + ", I'm " + age + ", and I'm not a citizen of the United Kingdom."); 24 | } 25 | 26 | /* EXERCISE 2 27 | TODO: You can use types to ensure operation outcomes. Run the code as is and then modify 28 | it to have strongly typed variables. Then, address any errors you find so that the result 29 | returned to a is 12. */ 30 | 31 | let x: number; 32 | let y: number; 33 | let a: number; 34 | 35 | x = 5; 36 | y = 7; 37 | a = x + y; 38 | 39 | console.log(a); 40 | 41 | /* EXERCISE 3 42 | TODO: In the following code, implement an enum type called Season that represents 43 | the constants "Fall", "Winter", "Spring", and "Summer". Then, update the function so 44 | you can pass in the season by referencing an item in the enum, for example 45 | Season.Fall, instead of the literal string "Fall". */ 46 | 47 | enum Season { 48 | Winter, 49 | Spring, 50 | Summer, 51 | Fall 52 | }; 53 | 54 | function whichMonths(season: Season) { 55 | let monthsInSeason: string; 56 | switch (season) { 57 | case Season.Fall: 58 | monthsInSeason = "September to November"; 59 | break; 60 | case Season.Winter: 61 | monthsInSeason = "December to February"; 62 | break; 63 | case Season.Spring: 64 | monthsInSeason = "March to May"; 65 | break; 66 | case Season.Summer: 67 | monthsInSeason = "June to August"; 68 | } 69 | return monthsInSeason; 70 | } 71 | 72 | console.log(whichMonths(Season.Spring)); 73 | 74 | /* EXERCISE 4 75 | TODO: Declare the array as the type to match the type of the items in the array. */ 76 | 77 | let randomNumbers: number[] = []; 78 | let nextNumber: number; 79 | 80 | for (let i = 0; i < 10; i++) { 81 | nextNumber = Math.floor(Math.random() * (100 - 1)) + 1; 82 | randomNumbers.push(nextNumber); 83 | } 84 | 85 | console.log(randomNumbers); 86 | -------------------------------------------------------------------------------- /code/module-02/m02-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-02/m02-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-02/m02-start/build/module02.js: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /code/module-02/m02-start/module02.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module02.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-02/m02-start/module02.ts: -------------------------------------------------------------------------------- 1 | /* Module 2: Declare variable types in TypeScript 2 | Lab start */ 3 | 4 | /* EXERCISE 1 5 | TODO: Modify the code to add types to the variable declarations. 6 | The resulting JavaScript should look the same as the original example when you're done. */ 7 | 8 | let firstName; 9 | let lastName; 10 | let fullName; 11 | let age; 12 | let ukCitizen; 13 | 14 | firstName = 'Rebecca'; 15 | lastName = 'Smith'; 16 | age = 42; 17 | ukCitizen = false; 18 | fullName = firstname + " " + lastname; 19 | 20 | if (ukCitizen) { 21 | console.log("My name is " + fullName + ", I'm " + age + ", and I'm a citizen of the United Kingdom."); 22 | } else { 23 | console.log("My name is " + fullName + ", I'm " + age + ", and I'm not a citizen of the United Kingdom."); 24 | } 25 | 26 | /* EXERCISE 2 27 | TODO: You can use types to ensure operation outcomes. Run the code as is and then modify 28 | it to have strongly typed variables. Then, address any errors you find so that the result 29 | returned to a is 12. */ 30 | 31 | let x; 32 | let y; 33 | let a; 34 | 35 | x = 'five'; 36 | y = 7; 37 | a = x + y; 38 | 39 | console.log(a); 40 | 41 | /* EXERCISE 3 42 | TODO: In the following code, implement an enum type called Season that represents 43 | the constants "Fall", "Winter", "Spring", and "Summer". Then, update the function so 44 | you can pass in the season by referencing an item in the enum, for example 45 | Season.Fall, instead of the literal string "Fall". */ 46 | 47 | function whichMonths(season) { 48 | 49 | let monthsInSeason: string; 50 | 51 | switch (season) { 52 | case "Fall": 53 | monthsInSeason = "September to November"; 54 | break; 55 | case "Winter": 56 | monthsInSeason = "December to February"; 57 | break; 58 | case "Spring": 59 | monthsInSeason = "March to May"; 60 | break; 61 | case "Summer": 62 | monthsInSeason = "June to August"; 63 | } 64 | 65 | return monthsInSeason; 66 | } 67 | 68 | console.log(whichMonths("Fall")); 69 | 70 | /* EXERCISE 4 71 | TODO: Declare the array as the type to match the type of the items in the array. */ 72 | 73 | let randomNumbers; 74 | let nextNumber; 75 | 76 | for (let i = 0; i < 10; i++) { 77 | nextNumber = Math.floor(Math.random() * (100 - 1)) + 1; 78 | randomNumbers.push(nextNumber); 79 | } 80 | 81 | console.log(randomNumbers); 82 | 83 | -------------------------------------------------------------------------------- /code/module-02/m02-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-02/m02-start/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-03/m03-end/build/module03.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* Module 3: Implement interfaces in TypeScript 3 | Lab End */ 4 | /* TODO: Replace the two parameters in the intOnlyLoan function with an object of 5 | type Loan (for example, loanTerms: Loan) and type the return value of the function 6 | as a string. 7 | 8 | Replace the parameter names in the function with properties of the Loan object. 9 | (For example, loanTerms.interestRate). 10 | 11 | Type the intr and pmt variables as numbers.*/ 12 | function intOnlyLoan(loanTerms) { 13 | // Calculates the monthly payment of an interest only loan 14 | let intr = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan 15 | let pmt; 16 | pmt = loanTerms.principle * intr; 17 | return 'The interest only loan payment is ' + pmt.toFixed(2); 18 | } 19 | /* TODO: Update the convLoan function, this time replacing the three parameters with an 20 | object of type ConvLoan and type the return value of the function as a string. */ 21 | function convLoan(loanTerms) { 22 | // Calculates the monthly payment of a conventional loan 23 | let intr = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan 24 | let pmt; 25 | pmt = loanTerms.principle * intr / (1 - (Math.pow(1 / (1 + intr), loanTerms.numMonths))); 26 | return 'The conventional loan payment is ' + pmt.toFixed(2); 27 | } 28 | let loan1 = intOnlyLoan({ principle: 30000, interestRate: 5 }); 29 | let loan2 = convLoan({ principle: 30000, interestRate: 5, numMonths: 180 }); 30 | console.log(loan1); //* Returns "The interest only loan payment is 125.00" 31 | console.log(loan2); //* Returns "The conventional loan payment is 237.24" 32 | -------------------------------------------------------------------------------- /code/module-03/m03-end/module03.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module03.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-03/m03-end/module03.ts: -------------------------------------------------------------------------------- 1 | /* Module 3: Implement interfaces in TypeScript 2 | Lab End */ 3 | 4 | /* EXERCISE 1 5 | TODO: Declare the Loan interface. */ 6 | 7 | interface Loan { 8 | principle: number, 9 | interestRate: number //* Interest rate percentage (eg. 14 is 14%) 10 | } 11 | 12 | /* TODO: Declare the ConventionalLoan interface. */ 13 | 14 | interface ConventionalLoan extends Loan { 15 | months: number //* Total number of months 16 | } 17 | 18 | /* TODO: Update the calculateInterestOnlyLoanPayment function. */ 19 | 20 | function calculateInterestOnlyLoanPayment(loanTerms: Loan): string { 21 | // Calculates the monthly payment of an interest only loan 22 | let interest: number = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan 23 | let payment: number; 24 | payment = loanTerms.principle * interest; 25 | return 'The interest only loan payment is ' + payment.toFixed(2); 26 | } 27 | 28 | /* TODO: Update the calculateConventionalLoanPayment function. */ 29 | 30 | function calculateConventionalLoanPayment(loanTerms: ConventionalLoan): string { 31 | // Calculates the monthly payment of a conventional loan 32 | let interest: number = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan 33 | let payment: number; 34 | payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months))); 35 | return 'The conventional loan payment is ' + payment.toFixed(2); 36 | } 37 | 38 | let interestOnlyPayment = calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5}); 39 | let conventionalPayment = calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180}); 40 | 41 | console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00" 42 | console.log(conventionalPayment); //* Returns "The conventional loan payment is 237.24" 43 | -------------------------------------------------------------------------------- /code/module-03/m03-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-03/m03-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-03/m03-start/build/module03.js: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /code/module-03/m03-start/module03.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module03.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-03/m03-start/module03.ts: -------------------------------------------------------------------------------- 1 | /* Module 3: Implement interfaces in TypeScript 2 | Lab Start */ 3 | 4 | /* EXERCISE 1 5 | TODO: Declare the Loan interface. */ 6 | 7 | 8 | /* TODO: Declare the ConventionalLoan interface. */ 9 | 10 | 11 | 12 | /* TODO: Update the calculateInterestOnlyLoanPayment function. */ 13 | 14 | function calculateInterestOnlyLoanPayment(principle, interestRate) { 15 | // Calculates the monthly payment of an interest only loan 16 | let interest = interestRate / 1200; // Calculates the Monthly Interest Rate of the loan 17 | let payment; 18 | payment = principle * interest; 19 | return 'The interest only loan payment is ' + payment.toFixed(2); 20 | } 21 | 22 | /* TODO: Update the calculateConventionalLoanPayment function. */ 23 | 24 | function calculateConventionalLoanPayment(principle, interestRate, months) { 25 | // Calculates the monthly payment of a conventional loan 26 | let interest = interestRate / 1200; // Calculates the Monthly Interest Rate of the loan 27 | let payment; 28 | payment = principle * interest / (1 - (Math.pow(1 / (1 + interest), months))); 29 | return 'The conventional loan payment is ' + payment.toFixed(2); 30 | } 31 | 32 | let interestOnlyPayment = calculateInterestOnlyLoanPayment(30000, 5); 33 | let conventionalPayment = calculateConventionalLoanPayment(30000, 5, 180); 34 | 35 | console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00" 36 | console.log(conventionalPayment); //* Returns "The conventional loan payment is 237.24" 37 | -------------------------------------------------------------------------------- /code/module-03/m03-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-03/m03-start/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-04/m04-end/build/module04.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* Module 4: Develop typed functions using TypeScript 3 | Lab End */ 4 | /* TODO: Convert the sortDescending and sortAscending functions to arrow 5 | functions and assign them to variables of the same name. Add types to the 6 | parameter lists and return values for each function. */ 7 | /* sortDescending is a comparison function that tells the sort method how to sort 8 | numbers in descending order */ 9 | let sortDescending = (a, b) => { 10 | if (a > b) { 11 | return -1; 12 | ; 13 | } 14 | else if (b > a) { 15 | return 1; 16 | ; 17 | } 18 | else { 19 | return 0; 20 | } 21 | }; 22 | /* sortDescending is a comparison function that tells the sort method how to sort 23 | numbers in ascending order. */ 24 | let sortAscending = (a, b) => { 25 | if (a > b) { 26 | return 1; 27 | } 28 | else if (b > a) { 29 | return -1; 30 | } 31 | else { 32 | return 0; 33 | } 34 | }; 35 | /* The buildArray function builds an array of unique random numbers containing the number 36 | of items based on the number passed to it. The sortOrder parameter determines 37 | whether to sort the array in ascending or descending order. */ 38 | /* TODO: In the BuildArray function, add types to parameter list, 39 | return value, and variables. */ 40 | function buildArray(items, sortOrder) { 41 | let randomNumbers = []; 42 | let nextNumber; 43 | for (let i = 0; i < items; i++) { 44 | nextNumber = Math.floor(Math.random() * (100 - 1)) + 1; 45 | if (randomNumbers.indexOf(nextNumber) === -1) { 46 | randomNumbers.push(nextNumber); 47 | } 48 | else { 49 | i--; 50 | } 51 | } 52 | if (sortOrder === 'ascending') { 53 | return randomNumbers.sort(sortAscending); 54 | } 55 | else { 56 | return randomNumbers.sort(sortDescending); 57 | } 58 | } 59 | let myArray1 = buildArray(12, 'ascending'); 60 | let myArray2 = buildArray(8, 'descending'); 61 | console.log(myArray1); 62 | console.log(myArray2); 63 | /* EXERCISE 2 64 | TODO: Convert the LoanCalc function to TypeScript with strongly typed parameters, variables, 65 | and return types. Make the numMonths parameter optional but assign it a default value of 12 66 | months if omitted. */ 67 | function LoanCalc(principle, interestRate, numMonths = 12) { 68 | let intr = interestRate / 1200; // Calculates the monthly interest rate 69 | let pmt; 70 | Number; 71 | pmt = principle * intr / (1 - (Math.pow(1 / (1 + intr), numMonths))); 72 | return pmt.toFixed(2); 73 | } 74 | let myLoan = LoanCalc(1000, 5); 75 | console.log(myLoan); 76 | -------------------------------------------------------------------------------- /code/module-04/m04-end/module04.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module04.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-04/m04-end/module04.ts: -------------------------------------------------------------------------------- 1 | /* Module 4: Develop typed functions using TypeScript 2 | Lab End */ 3 | 4 | /* EXERCISE 1 5 | TODO: Declare a new function type for the sortDescending and sortAscending functions. */ 6 | 7 | type compareFunctionType = (a: number, b:number) => number; 8 | 9 | /* TODO: Convert the sortDescending and sortAscending functions to arrow 10 | functions. */ 11 | 12 | /* sortDescending is a comparison function that tells the sort method how to sort 13 | numbers in descending order */ 14 | let sortDescending: compareFunctionType = (a, b) => { 15 | if (a > b) { 16 | return -1; 17 | } else if (b > a) { 18 | return 1; 19 | } else { 20 | return 0; 21 | } 22 | } 23 | 24 | /* sortDescending is a comparison function that tells the sort method how to sort 25 | numbers in ascending order. */ 26 | let sortAscending: compareFunctionType = (a, b) => { 27 | if (a > b) { 28 | return 1; 29 | } else if (b > a) { 30 | return -1; 31 | } else { 32 | return 0; 33 | } 34 | } 35 | 36 | /* The buildArray function builds an array of unique random numbers containing the number 37 | of items based on the number passed to it. The sortOrder parameter determines 38 | whether to sort the array in ascending or descending order. */ 39 | 40 | /* TODO: Update the BuildArray function. */ 41 | 42 | function buildArray(items: number, sortOrder: 'ascending' | 'descending'): number[] { 43 | let randomNumbers: number[] = []; 44 | let nextNumber: number; 45 | for (let counter = 0; counter < items; counter++) { 46 | nextNumber = Math.ceil(Math.random() * (100 - 1)); 47 | if (randomNumbers.indexOf(nextNumber) === -1) { 48 | randomNumbers.push(nextNumber); 49 | } else { 50 | counter--; 51 | } 52 | } 53 | if (sortOrder === 'ascending') { 54 | return randomNumbers.sort(sortAscending); 55 | } else { 56 | return randomNumbers.sort(sortDescending); 57 | } 58 | } 59 | 60 | let myArray1 = buildArray(12, 'ascending'); 61 | let myArray2 = buildArray(8, 'descending'); 62 | console.log(myArray1); 63 | console.log(myArray2); 64 | 65 | /* EXERCISE 2 66 | TODO: Update the LoanCalculator function. */ 67 | 68 | function loanCalculator (principle: number, interestRate: number, months = 12): string { 69 | let interest: number = interestRate / 1200; // Calculates the monthly interest rate 70 | let payment: number; 71 | payment = principle * interest / (1 - (Math.pow(1/(1 + interest), months))); 72 | return payment.toFixed(2); 73 | } 74 | 75 | let myLoan = loanCalculator(1000, 5); 76 | console.log(myLoan); 77 | -------------------------------------------------------------------------------- /code/module-04/m04-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-04/m04-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-04/m04-start/build/module04.js: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /code/module-04/m04-start/module04.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module04.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-04/m04-start/module04.ts: -------------------------------------------------------------------------------- 1 | /* Module 4: Develop typed functions using TypeScript 2 | Lab Start */ 3 | 4 | /* EXERCISE 1 5 | TODO: Declare a new function type for the sortDescending and sortAscending functions. */ 6 | 7 | 8 | /* TODO: Convert the sortDescending and sortAscending functions to arrow 9 | functions. */ 10 | 11 | /* sortDescending is a comparison function that tells the sort method how to sort 12 | numbers in descending order */ 13 | function sortDescending(a, b) { 14 | if (a > b) { 15 | return -1; 16 | } else if (b > a) { 17 | return 1; 18 | } else { 19 | return 0; 20 | } 21 | } 22 | 23 | /* sortDescending is a comparison function that tells the sort method how to sort 24 | numbers in ascending order. */ 25 | function sortAscending(a, b) { 26 | if (a > b) { 27 | return 1; 28 | } else if (b > a) { 29 | return -1; 30 | } else { 31 | return 0; 32 | } 33 | } 34 | 35 | /* The buildArray function builds an array of unique random numbers containing the number 36 | of items based on the number passed to it. The sortOrder parameter determines 37 | whether to sort the array in ascending or descending order. */ 38 | 39 | /* TODO: Update the BuildArray function. */ 40 | 41 | function buildArray(items, sortOrder) { 42 | let randomNumbers = []; 43 | let nextNumber; 44 | for (let counter = 0; counter < items; counter++) { 45 | nextNumber = Math.ceil(Math.random() * (100 - 1)); 46 | if (randomNumbers.indexOf(nextNumber) === -1) { 47 | randomNumbers.push(nextNumber); 48 | } else { 49 | counter--; 50 | } 51 | } 52 | if (sortOrder === 'ascending') { 53 | return randomNumbers.sort(sortAscending); 54 | } else { 55 | return randomNumbers.sort(sortDescending); 56 | } 57 | } 58 | 59 | let myArray1 = buildArray(12, 'ascending'); 60 | let myArray2 = buildArray(8, 'descending'); 61 | 62 | /* EXERCISE 2 63 | TODO: Update the LoanCalculator function. */ 64 | 65 | function loanCalculator (principle, interestRate, months) { 66 | let interest = interestRate / 1200; // Calculates the monthly interest rate 67 | let payment; 68 | payment = principle * interest / (1 - (Math.pow(1/(1 + interest), months))); 69 | return payment.toFixed(2); 70 | } 71 | -------------------------------------------------------------------------------- /code/module-04/m04-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-04/m04-start/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-05/m05-end/build/module05.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // Comparison function that tells the sort method how to sort numbers in descending order 3 | let sortDescending2 = (a, b) => { 4 | if (a > b) { 5 | return -1; 6 | ; 7 | } 8 | else if (b > a) { 9 | return 1; 10 | ; 11 | } 12 | else { 13 | return 0; 14 | } 15 | }; 16 | // Comparison function that tells the sort method how to sort numbers in ascending order 17 | let sortAscending2 = (a, b) => { 18 | if (a > b) { 19 | return 1; 20 | } 21 | else if (b > a) { 22 | return -1; 23 | } 24 | else { 25 | return 0; 26 | } 27 | }; 28 | // This function builds an array of unique random numbers containing the number of items based on the number passed to it. 29 | // The sortOrder parameter determines whether to sort the array in ascending or decending order. 30 | function buildArray2(items, sortOrder) { 31 | let randomNumbers = []; 32 | let nextNumber; 33 | for (let i = 0; i < items; i++) { 34 | nextNumber = Math.floor(Math.random() * (100 - 1)) + 1; 35 | if (randomNumbers.indexOf(nextNumber) === -1) { 36 | randomNumbers.push(nextNumber); 37 | } 38 | else { 39 | i--; 40 | } 41 | } 42 | if (sortOrder === 'ascending') { 43 | return randomNumbers.sort(sortAscending2); 44 | } 45 | else { 46 | return randomNumbers.sort(sortDescending2); 47 | } 48 | } 49 | let testArray1 = buildArray2(12, 'ascending'); 50 | let testArray2 = buildArray2(8, 'descending'); 51 | console.log(testArray1); 52 | console.log(testArray2); 53 | -------------------------------------------------------------------------------- /code/module-05/m05-end/module05.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module05.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-05/m05-end/module05.ts: -------------------------------------------------------------------------------- 1 | /* Module 5: Declare and instantiate classes in TypeScript 2 | Lab End */ 3 | 4 | /* EXERCISE 1 */ 5 | 6 | class BuildArray { 7 | // TODO Define the properties 8 | private _items: number; 9 | private _sortOrder: 'ascending' | 'descending'; 10 | 11 | // TODO Define the constructor 12 | constructor (items: number, sortOrder: 'ascending' | 'descending') { 13 | this._items = items; 14 | this._sortOrder = sortOrder; 15 | } 16 | 17 | // TODO Define the accessors 18 | get items() { 19 | return this._items; 20 | } 21 | set items(items) { 22 | this._items = items; 23 | } 24 | get sortOrder() { 25 | return this._sortOrder; 26 | } 27 | set sortOrder(sortOrder) { 28 | this._sortOrder = sortOrder; 29 | } 30 | 31 | // TODO Define the methods. 32 | private sortDescending = (a: number, b: number) => { 33 | if (a > b) { 34 | return -1; 35 | } else if (b > a) { 36 | return 1; 37 | } else { 38 | return 0;} 39 | } 40 | private sortAscending = (a: number, b: number) => { 41 | if (a > b) { 42 | return 1; 43 | } else if (b > a) { 44 | return -1; 45 | } else { 46 | return 0; } 47 | } 48 | buildArray(): number[] { 49 | let randomNumbers: number[] = []; 50 | let nextNumber: number; 51 | for (let counter = 0; counter < this.items; counter++) { 52 | nextNumber = Math.ceil(Math.random() * (100 - 1)); 53 | if (randomNumbers.indexOf(nextNumber) === -1) { 54 | randomNumbers.push(nextNumber); 55 | } else { 56 | counter--; 57 | } 58 | } 59 | if (this._sortOrder === 'ascending') { 60 | return randomNumbers.sort(this.sortAscending); 61 | } else { 62 | return randomNumbers.sort(this.sortDescending); 63 | } 64 | } 65 | } 66 | 67 | /* TODO: Instantiate the BuildArray objects. */ 68 | 69 | let testArray1 = new BuildArray(12, 'ascending'); 70 | let testArray2 = new BuildArray(8, 'descending'); 71 | 72 | console.log(testArray1.buildArray()); 73 | console.log(testArray2.buildArray()); 74 | -------------------------------------------------------------------------------- /code/module-05/m05-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-05/m05-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-05/m05-start/build/module05.js: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /code/module-05/m05-start/module05.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module05.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-05/m05-start/module05.ts: -------------------------------------------------------------------------------- 1 | /* Module 5: Declare and instantiate classes in TypeScript 2 | Lab Start */ 3 | 4 | /* EXERCISE 1 */ 5 | 6 | class BuildArray { 7 | // TODO Define the properties 8 | 9 | // TODO Define the constructor 10 | 11 | // TODO Define the accessors 12 | 13 | // TODO Define the methods 14 | 15 | } 16 | 17 | /* sortDescending is a comparison function that tells the sort method how to sort numbers 18 | in descending order. */ 19 | let sortDescending = (a: number, b: number) => { 20 | if (a > b) { 21 | return -1; 22 | } else if (b > a) { 23 | return 1; 24 | } else { 25 | return 0; } 26 | } 27 | 28 | /* sortAscending is a comparison function that tells the sort method how to sort numbers 29 | in ascending order. */ 30 | let sortAscending = (a: number, b: number) => { 31 | if (a > b) { 32 | return 1; 33 | } else if (b > a) { 34 | return -1; 35 | } else { 36 | return 0; 37 | } 38 | } 39 | 40 | /* buildArray builds an array of unique random numbers containing the number of items 41 | based on the number passed to it. The sortOrder parameter determines whether to sort 42 | the array in ascending or descending order. */ 43 | function buildArray(items: number, sortOrder: 'ascending' | 'descending'): number[] { 44 | let randomNumbers: number[] = []; 45 | let nextNumber: number; 46 | for (let counter = 0; counter < items; counter++) { 47 | nextNumber = Math.ceil(Math.random() * (100 - 1)); 48 | if (randomNumbers.indexOf(nextNumber) === -1) { 49 | randomNumbers.push(nextNumber); 50 | } else { 51 | counter--; 52 | } 53 | } 54 | if (sortOrder === 'ascending') { 55 | return randomNumbers.sort(sortAscending); 56 | } else { 57 | return randomNumbers.sort(sortDescending); 58 | } 59 | } 60 | 61 | /* TODO: Instantiate the BuildArray objects. */ 62 | 63 | let testArray1 = buildArray(12, 'ascending'); 64 | let testArray2 = buildArray(8, 'descending'); 65 | console.log(testArray1); 66 | console.log(testArray2); 67 | -------------------------------------------------------------------------------- /code/module-05/m05-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-05/m05-start/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-06/m06-end/build/module06.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* Module 6: DGenerics in TypeScript 3 | Lab End */ 4 | /* DataStore is a utility function that can store up to 10 string values in an array. 5 | Rewrite the DataStore class so the array can store items of any type. */ 6 | // TODO: Add a type variable called T to the class declaration. 7 | class DataStore { 8 | constructor() { 9 | //TODO: Add the type variable to the _data property declaration. 10 | this._data = new Array(10); 11 | } 12 | //TODO: Update the type of the item parameter in the AddOrUpdate function to use the type variable. 13 | AddOrUpdate(index, item) { 14 | if (index >= 0 && index < 10) { 15 | this._data[index] = item; 16 | } 17 | } 18 | GetData(index) { 19 | if (index >= 0 && index < 10) { 20 | return this._data[index]; 21 | } 22 | else { 23 | return; 24 | } 25 | } 26 | } 27 | let cities = new DataStore(); 28 | cities.AddOrUpdate(0, "Mumbai"); 29 | cities.AddOrUpdate(1, "Chicago"); 30 | cities.AddOrUpdate(2, "London"); 31 | cities.AddOrUpdate(11, "New York"); 32 | console.log(cities.GetData(11)); // returns 'undefined' 33 | // TODO Test items as numbers 34 | let empIDs = new DataStore(); 35 | empIDs.AddOrUpdate(0, 50); 36 | empIDs.AddOrUpdate(1, 65); 37 | empIDs.AddOrUpdate(2, 89); 38 | console.log(empIDs.GetData(0)); // returns 50 39 | let pets = new DataStore(); 40 | pets.AddOrUpdate(0, { name: 'Rex', breed: 'Golden Retriever', age: 5 }); 41 | pets.AddOrUpdate(1, { name: 'Sparky', breed: 'Jack Russell Terrier', age: 3 }); 42 | console.log(pets.GetData(1)); // returns { name: 'Sparky', breed: 'Jack Russell Terrier', age: 3} 43 | -------------------------------------------------------------------------------- /code/module-06/m06-end/module06.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module06.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-06/m06-end/module06.ts: -------------------------------------------------------------------------------- 1 | /* Module 6: DGenerics in TypeScript 2 | Lab End */ 3 | 4 | /* DataStore is a utility function that can store up to 10 string values in an array. 5 | Rewrite the DataStore class so the array can store items of any type. */ 6 | 7 | // TODO: Add and apply a type variable. 8 | class DataStore { 9 | 10 | private _data: Array = new Array(10); 11 | 12 | AddOrUpdate(index: number, item: T) { 13 | if(index >=0 && index <10) { 14 | this._data[index] = item; 15 | } 16 | } 17 | GetData(index: number) { 18 | if(index >=0 && index < 10) { 19 | return this._data[index]; 20 | } else { 21 | return 22 | } 23 | } 24 | 25 | } 26 | 27 | let cities = new DataStore(); 28 | cities.AddOrUpdate(0, "Mumbai"); 29 | cities.AddOrUpdate(1, "Chicago"); 30 | cities.AddOrUpdate(2, "London"); 31 | cities.AddOrUpdate(11, "New York"); 32 | console.log(cities.GetData(11)); // returns 'undefined' 33 | 34 | // TODO Test items as numbers. 35 | let empIDs = new DataStore(); 36 | empIDs.AddOrUpdate(0, 50); 37 | empIDs.AddOrUpdate(1, 65); 38 | empIDs.AddOrUpdate(2, 89); 39 | console.log(empIDs.GetData(0)); // returns 50 40 | 41 | // TODO Test items as objects. 42 | type Pets = { 43 | name: string; 44 | breed: string; 45 | age: number 46 | } 47 | let pets = new DataStore(); 48 | pets.AddOrUpdate(0, { name: 'Rex', breed: 'Golden Retriever', age: 5}); 49 | pets.AddOrUpdate(1, { name: 'Sparky', breed: 'Jack Russell Terrier', age: 3}); 50 | console.log(pets.GetData(1)); // returns { name: 'Sparky', breed: 'Jack Russell Terrier', age: 3} 51 | -------------------------------------------------------------------------------- /code/module-06/m06-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-06/m06-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-06/m06-start/build/module06.js: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /code/module-06/m06-start/module06.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module06.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-06/m06-start/module06.ts: -------------------------------------------------------------------------------- 1 | /* Module 6: DGenerics in TypeScript 2 | Lab Start */ 3 | 4 | /* DataStore is a utility function that can store up to 10 string values in an array. 5 | Rewrite the DataStore class so the array can store items of any type. 6 | 7 | TODO: Add and apply a type variable. */ 8 | class DataStore { 9 | 10 | private _data = new Array(10); 11 | 12 | AddOrUpdate(index: number, item: string) { 13 | if(index >=0 && index <10) { 14 | this._data[index] = item; 15 | } else { 16 | alert('Index is greater than 10') 17 | } 18 | } 19 | GetData(index: number) { 20 | if(index >=0 && index < 10) { 21 | return this._data[index]; 22 | } else { 23 | return 24 | } 25 | } 26 | } 27 | 28 | let cities = new DataStore(); 29 | 30 | cities.AddOrUpdate(0, "Mumbai"); 31 | cities.AddOrUpdate(1, "Chicago"); 32 | cities.AddOrUpdate(11, "London"); // item not added 33 | 34 | console.log(cities.GetData(1)); // returns 'Chicago' 35 | console.log(cities.GetData(12)); // returns 'undefined' 36 | 37 | // TODO Test items as numbers. 38 | 39 | 40 | // TODO Test items as objects. 41 | -------------------------------------------------------------------------------- /code/module-06/m06-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-06/m06-start/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /code/module-07/m07-end/module07.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module08_main.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-07/m07-end/module07_loan-programs.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | exports.calculateConventionalLoanPayment = exports.calculateInterestOnlyLoanPayment = void 0; 4 | /* TODO Update the calculateInterestOnlyLoanPayment function. */ 5 | function calculateInterestOnlyLoanPayment(loanTerms) { 6 | var payment; 7 | payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate); 8 | return 'The interest only loan payment is ' + payment.toFixed(2); 9 | } 10 | exports.calculateInterestOnlyLoanPayment = calculateInterestOnlyLoanPayment; 11 | /* TODO Update the calculateConventionalLoanPayment function. */ 12 | function calculateConventionalLoanPayment(loanTerms) { 13 | var interest = calculateInterestRate(loanTerms.interestRate); 14 | var payment; 15 | payment = loanTerms.principle * interest / (1 - (Math.pow(1 / (1 + interest), loanTerms.months))); 16 | return 'The conventional loan payment is ' + payment.toFixed(2); 17 | } 18 | exports.calculateConventionalLoanPayment = calculateConventionalLoanPayment; 19 | function calculateInterestRate(interestRate) { 20 | var interest = interestRate / 1200; 21 | return interest; 22 | } 23 | -------------------------------------------------------------------------------- /code/module-07/m07-end/module07_loan-programs.ts: -------------------------------------------------------------------------------- 1 | /* TODO Add the import statement. */ 2 | import * as Loans from './module07_loans.js'; 3 | 4 | /* TODO Update the calculateInterestOnlyLoanPayment function. */ 5 | export function calculateInterestOnlyLoanPayment(loanTerms: Loans.Loan): string { 6 | let payment: number; 7 | payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate); 8 | return 'The interest only loan payment is ' + payment.toFixed(2); 9 | } 10 | /* TODO Update the calculateConventionalLoanPayment function. */ 11 | export function calculateConventionalLoanPayment(loanTerms: Loans.ConventionalLoan): string { 12 | let interest: number = calculateInterestRate(loanTerms.interestRate); 13 | let payment: number; 14 | payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months))); 15 | return 'The conventional loan payment is ' + payment.toFixed(2); 16 | } 17 | function calculateInterestRate (interestRate: number): number { 18 | let interest: number = interestRate / 1200; 19 | return interest 20 | } -------------------------------------------------------------------------------- /code/module-07/m07-end/module07_loans.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | -------------------------------------------------------------------------------- /code/module-07/m07-end/module07_loans.ts: -------------------------------------------------------------------------------- 1 | /* TODO Update the interface declarations. */ 2 | export interface Loan { 3 | principle: number, 4 | interestRate: number //* Interest rate percentage (eg. 14 is 14%) 5 | } 6 | export interface ConventionalLoan extends Loan { 7 | months: number //* Total number of months 8 | } -------------------------------------------------------------------------------- /code/module-07/m07-end/module07_main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* Module 7: Working with external libraries 3 | Lab Start */ 4 | exports.__esModule = true; 5 | /* TODO Add the import statement. */ 6 | var LoanPrograms = require("./module07_loan-programs.js"); 7 | /* TODO Update the function calls. */ 8 | var interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({ principle: 30000, interestRate: 5 }); 9 | var conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({ principle: 30000, interestRate: 5, months: 180 }); 10 | console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00" 11 | console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24" 12 | -------------------------------------------------------------------------------- /code/module-07/m07-end/module07_main.ts: -------------------------------------------------------------------------------- 1 | /* Module 7: Working with external libraries 2 | Lab Start */ 3 | 4 | /* TODO Add the import statement. */ 5 | import * as LoanPrograms from './module07_loan-programs.js'; 6 | 7 | /* TODO Update the function calls. */ 8 | let interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5}); 9 | let conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180}); 10 | console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00" 11 | console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24" 12 | -------------------------------------------------------------------------------- /code/module-07/m07-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-07/m07-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } 9 | -------------------------------------------------------------------------------- /code/module-07/m07-start/module07.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module08_main.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-07/m07-start/module07_loan-programs.ts: -------------------------------------------------------------------------------- 1 | /* TODO Add the import statement. */ 2 | 3 | /* TODO Update the calculateInterestOnlyLoanPayment function. */ 4 | function calculateInterestOnlyLoanPayment(loanTerms: Loan): string { 5 | let payment: number; 6 | payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate); 7 | return 'The interest only loan payment is ' + payment.toFixed(2); 8 | } 9 | /* TODO Update the calculateConventionalLoanPayment function. */ 10 | function calculateConventionalLoanPayment(loanTerms: ConventionalLoan): string { 11 | let interest: number = calculateInterestRate(loanTerms.interestRate); 12 | let payment: number; 13 | payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months))); 14 | return 'The conventional loan payment is ' + payment.toFixed(2); 15 | } 16 | function calculateInterestRate (interestRate: number): number { 17 | let interest: number = interestRate / 1200; 18 | return interest 19 | } -------------------------------------------------------------------------------- /code/module-07/m07-start/module07_loans.ts: -------------------------------------------------------------------------------- 1 | /* TODO Update the interface declarations. */ 2 | interface Loan { 3 | principle: number, 4 | interestRate: number //* Interest rate percentage (eg. 14 is 14%) 5 | } 6 | interface ConventionalLoan extends Loan { 7 | months: number //* Total number of months 8 | } -------------------------------------------------------------------------------- /code/module-07/m07-start/module07_main.ts: -------------------------------------------------------------------------------- 1 | /* Module 7: Working with external libraries 2 | Lab Start */ 3 | 4 | /* TODO Add the import statement. */ 5 | 6 | /* TODO Update the function calls. */ 7 | let interestOnlyPayment = calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5}); 8 | let conventionalLoanPayment = calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180}); 9 | console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00" 10 | console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24" 11 | -------------------------------------------------------------------------------- /code/module-07/m07-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-07/m07-start/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } 9 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/greetings-utilities_module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | exports.returnGreeting = void 0; 4 | // Returns the value of a parameter and the parameter length to the console. 5 | function returnGreeting(greeting) { 6 | var greetingLength = getLength(greeting); 7 | console.log("The message from namespace GreetingsWithLength is " + greeting + ". It is " + greetingLength + " characters long."); 8 | } 9 | exports.returnGreeting = returnGreeting; 10 | function getLength(message) { 11 | return message.length; 12 | } 13 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/greetings-utilities_module.ts: -------------------------------------------------------------------------------- 1 | // Returns the value of a parameter and the parameter length to the console. 2 | export function returnGreeting (greeting: string) { 3 | let greetingLength = getLength(greeting); 4 | console.log(`The message from namespace GreetingsWithLength is ${greeting}. It is ${greetingLength} characters long.`); 5 | } 6 | function getLength(message: string): number { 7 | return message.length 8 | } 9 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/greetings_module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | exports.returnGreeting = void 0; 4 | // Returns the value of a parameter to the console. 5 | function returnGreeting(greeting) { 6 | console.log("The message from namespace Greetings is " + greeting + "."); 7 | } 8 | exports.returnGreeting = returnGreeting; 9 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/greetings_module.ts: -------------------------------------------------------------------------------- 1 | // Returns the value of a parameter to the console. 2 | export function returnGreeting (greeting: string) { 3 | console.log(`The message from namespace Greetings is ${greeting}.`); 4 | } -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | var greetings_module_js_1 = require("./greetings_module.js"); // imports a single function in the module 4 | var allGreetingFunctions = require("./greetings_module.js"); // imports all exported components in the module 5 | var greetings_utilities_module_js_1 = require("./greetings-utilities_module.js"); 6 | greetings_module_js_1.returnGreeting('Hola!'); // Displays 'The message from Greetings_module is Hola!' 7 | allGreetingFunctions.returnGreeting('Bonjour'); // Displays 'The message from Greetings_module is Bonjour!' 8 | greetings_utilities_module_js_1.returnGreeting('Ciao!'); // Displays 'The message from GreetingsWithLength_module is Ciao! It is 5 characters long.' 9 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/main.ts: -------------------------------------------------------------------------------- 1 | import { returnGreeting } from './greetings_module.js'; // imports a single function in the module 2 | import * as allGreetingFunctions from './greetings_module.js'; // imports all exported components in the module 3 | import { returnGreeting as returnGreetingLength } from './greetings-utilities_module.js'; 4 | 5 | returnGreeting('Hola!') // Displays 'The message from Greetings_module is Hola!' 6 | allGreetingFunctions.returnGreeting('Bonjour'); // Displays 'The message from Greetings_module is Bonjour!' 7 | returnGreetingLength('Ciao!'); // Displays 'The message from GreetingsWithLength_module is Ciao! It is 5 characters long.' -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/module07-exercise.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | // "outDir": "./", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-01-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } 9 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-02-end/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | var dotenv_1 = __importDefault(require("dotenv")); 7 | var result = dotenv_1.default.config(); 8 | if (result.error) { 9 | throw result.error; 10 | } 11 | console.log(result.parsed); 12 | console.log(process.env.DB_HOST); 13 | console.log(process.env.DB_USER); 14 | console.log(process.env.DB_PASS); 15 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-02-end/main.ts: -------------------------------------------------------------------------------- 1 | 2 | import dotenv from 'dotenv'; 3 | 4 | const result = dotenv.config(); 5 | 6 | if (result.error) { 7 | throw result.error; 8 | } 9 | 10 | console.log(result.parsed); 11 | console.log(process.env.DB_HOST); 12 | console.log(process.env.DB_USER); 13 | console.log(process.env.DB_PASS); 14 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-02-end/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "requires": true, 3 | "lockfileVersion": 1, 4 | "dependencies": { 5 | "@types/dotenv": { 6 | "version": "8.2.0", 7 | "resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz", 8 | "integrity": "sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw==", 9 | "requires": { 10 | "dotenv": "*" 11 | } 12 | }, 13 | "@types/node": { 14 | "version": "14.14.20", 15 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.20.tgz", 16 | "integrity": "sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==" 17 | }, 18 | "dotenv": { 19 | "version": "8.2.0", 20 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", 21 | "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /code/module-07/module07-exercise-02-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | // "outDir": "./", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-08/m08-end/module08.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module08_main.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-08/m08-end/module08_loan-programs.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | namespace LoanPrograms { 4 | // Calculates the monthly payment of an interest only loan 5 | export function calculateInterestOnlyLoanPayment(loanTerms: Loans.Loan): string { 6 | let payment: number; 7 | payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate); 8 | return 'The interest only loan payment is ' + payment.toFixed(2); 9 | } 10 | // Calculates the monthly payment of a conventional loan 11 | export function calculateConventionalLoanPayment(loanTerms: Loans.ConventionalLoan): string { 12 | let interest: number = calculateInterestRate(loanTerms.interestRate); 13 | let payment: number; 14 | payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months))); 15 | return 'The conventional loan payment is ' + payment.toFixed(2); 16 | } 17 | function calculateInterestRate (interestRate: number): number { 18 | let interest: number = interestRate / 1200; 19 | return interest 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /code/module-08/m08-end/module08_loans.ts: -------------------------------------------------------------------------------- 1 | 2 | namespace Loans { 3 | export interface Loan { 4 | principle: number, 5 | interestRate: number //* Interest rate percentage (eg. 14 is 14%) 6 | } 7 | export interface ConventionalLoan extends Loan { 8 | months: number //* Total number of months 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /code/module-08/m08-end/module08_main.ts: -------------------------------------------------------------------------------- 1 | /* Module 8: Organize code using Typescript namespaces 2 | Lab End */ 3 | 4 | // Interfaces moved to module08_loans.ts 5 | 6 | // Functions moved to module08_loan-programs.ts 7 | 8 | /* TODO Add reference paths. */ 9 | /// 10 | /// 11 | 12 | /* TODO Update the function calls. */ 13 | let interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5}); 14 | let conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180}); 15 | console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00" 16 | console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24" 17 | -------------------------------------------------------------------------------- /code/module-08/m08-end/readme.md: -------------------------------------------------------------------------------- 1 | ## Using the Lab start and end solution files 2 | 3 | You can use the TypeScript [Playground](https://www.typescriptlang.org/play), Visual Studio Code, or any TypeScript-compatible IDE to complete the labs in the "Developing JavaScript applications using TypeScript" [LINK TO the Developing JavaScript applications using TypeScript] learning path. 4 | 5 | The **start** and **end** solutions for each lab are located in the **code** folder. In each lab, you will be provided with a link to each folder, as appropriate, for easy access. 6 | 7 | ### Setup Visual Studio Code 8 | 9 | If you want to use Visual Studio Code to run any of the **start** or **end** solution workspaces in the **code** folder, you must first set up your development environment. 10 | 11 | Install the following software on your machine: 12 | 13 | 1. Visual Studio Code (or IDE of your choice) 14 | 2. Node Package Manager (npm) 15 | 3. TypeScript Compiler (tsc) 16 | 17 | For best results, follow the complete instructions for setting up your environment and using the TypeScript compiler in [LINK TO Module 01: Get started with TypeScript ]. After setting up your environment, you can run any of the Lab solution files in the "Developing JavaScript applications using TypeScript" [LINK TO the Developing JavaScript applications using TypeScript] learning path. 18 | 19 | ### Playground 20 | 21 | If you’re using the Playground, you can copy and paste the start code from the Lab instructions into the editor. The solution to the lab exercises will be located in the **end** folder in the **module##.ts** file, which you can open in any text editor. 22 | -------------------------------------------------------------------------------- /code/module-08/m08-end/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-08/m08-end/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } 9 | -------------------------------------------------------------------------------- /code/module-08/m08-start/build/module08_main.js: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /code/module-08/m08-start/module08.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test JavaScript 6 | 7 | 8 |

Test JavaScript

9 |

10 |

This page calls the script module08_main.js and is used for testing.

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /code/module-08/m08-start/module08_main.ts: -------------------------------------------------------------------------------- 1 | /* Module 8: Organize code using TypeScript namespaces 2 | Lab Start */ 3 | 4 | /* TODO Create a the Loans namespace. */ 5 | 6 | 7 | interface Loan { 8 | principle: number, 9 | interestRate: number //* Interest rate percentage (eg. 14 is 14%) 10 | } 11 | interface ConventionalLoan extends Loan { 12 | months: number //* Total number of months 13 | } 14 | 15 | /* TODO Create LoanPrograms namespace. */ 16 | 17 | 18 | /* TODO Update the calculateInterestOnlyLoanPayment function. */ 19 | function calculateInterestOnlyLoanPayment(loanTerms: Loan): string { 20 | let payment: number; 21 | payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate); 22 | return 'The interest only loan payment is ' + payment.toFixed(2); 23 | } 24 | /* TODO Update the calculateConventionalLoanPayment function. */ 25 | function calculateConventionalLoanPayment(loanTerms: ConventionalLoan): string { 26 | let interest: number = calculateInterestRate(loanTerms.interestRate); 27 | let payment: number; 28 | payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months))); 29 | return 'The conventional loan payment is ' + payment.toFixed(2); 30 | } 31 | function calculateInterestRate (interestRate: number): number { 32 | let interest: number = interestRate / 1200; 33 | return interest 34 | } 35 | 36 | /* TODO Add reference paths. */ 37 | 38 | /* TODO Update the function calls. */ 39 | 40 | let interestOnlyPayment = calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5}); 41 | let conventionalLoanPayment = calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180}); 42 | console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00" 43 | console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24" 44 | -------------------------------------------------------------------------------- /code/module-08/m08-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "build", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /code/module-08/m08-start/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } 9 | -------------------------------------------------------------------------------- /code/readme.md: -------------------------------------------------------------------------------- 1 | ## Using the Lab start and end solution files 2 | 3 | You can use the TypeScript [Playground](https://www.typescriptlang.org/play), Visual Studio Code, or any TypeScript-compatible IDE to complete the labs in the "Developing JavaScript applications using TypeScript" [LINK TO the Developing JavaScript applications using TypeScript] learning path. 4 | 5 | The **start** and **end** solutions for each lab are located in the **code** folder. In each lab, you will be provided with a link to each folder, as appropriate, for easy access. 6 | 7 | ### Setup Visual Studio Code 8 | 9 | If you want to use Visual Studio Code to run any of the **start** or **end** solution workspaces in the **code** folder, you must first set up your development environment. 10 | 11 | Install the following software on your machine: 12 | 13 | 1. Visual Studio Code (or IDE of your choice) 14 | 2. Node Package Manager (npm) 15 | 3. TypeScript Compiler (tsc) 16 | 17 | For best results, follow the complete instructions for setting up your environment and using the TypeScript compiler in [LINK TO Module 01: Get started with TypeScript ]. After setting up your environment, you can run any of the Lab solution files in the "Developing JavaScript applications using TypeScript" [LINK TO the Developing JavaScript applications using TypeScript] learning path. 18 | 19 | ### Playground 20 | 21 | If you’re using the Playground, you can copy and paste the start code from the Lab instructions into the editor. The solution to the lab exercises will be located in the **end** folder in the **module##.ts** file, which you can open in any text editor. 22 | --------------------------------------------------------------------------------