Skip to content

Commit bc2c5de

Browse files
committed
improvement: added type safe function calls
1 parent 63afd27 commit bc2c5de

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

web-app/js/projects.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,33 @@ function getProjectHTML(projectName) {
3636

3737
function initializeProject(projectName) {
3838
const initializers = {
39-
'tic-tac-toe': initTicTacToe,
40-
'rock-paper-scissor': initRockPaperScissor,
41-
'dice-rolling': initDiceRolling,
42-
'coin-flip': initCoinFlip,
43-
'number-guessing': initNumberGuessing,
44-
'hangman': initHangman,
45-
'flames': initFlames,
46-
'emoji-memory': initEmojiMemoryGame,
47-
'fibonacci': initFibonacci,
48-
'progression-recognizer': initProgressionRecognizer,
49-
'pascal-triangle': initPascalTriangle,
50-
'armstrong': initArmstrong,
51-
'calculator': initCalculator,
52-
'collatz': initCollatz,
53-
'prime-analyzer': initPrimeAnalyzer,
54-
'projectile-motion': initProjectileMotion,
55-
'coordinate-polar-transform': initCoordinatePolarTransform,
56-
'derivative-calculator': initDerivativeCalculator,
57-
'morse-code': initMorseCode,
58-
'tower-of-hanoi': initTowerOfHanoi,
59-
'number-converter': initNumberConverter,
60-
'typing-speed-tester': initTypingSpeedTester,
61-
'snake-game': initSnakeGame,
62-
'spot-the-difference': initSpotTheDifference,
63-
'whack-a-mole': initWhackaMole,
39+
'tic-tac-toe': typeof initTicTacToe !== 'undefined' ? initTicTacToe : () => { },
40+
'rock-paper-scissor': typeof initRockPaperScissor !== 'undefined' ? initRockPaperScissor : () => { },
41+
'dice-rolling': typeof initDiceRolling !== 'undefined' ? initDiceRolling : () => { },
42+
'coin-flip': typeof initCoinFlip !== 'undefined' ? initCoinFlip : () => { },
43+
'number-guessing': typeof initNumberGuessing !== 'undefined' ? initNumberGuessing : () => { },
44+
'hangman': typeof initHangman !== 'undefined' ? initHangman : () => { },
45+
'flames': typeof initFlames !== 'undefined' ? initFlames : () => { },
46+
'emoji-memory': typeof initEmojiMemoryGame !== 'undefined' ? initEmojiMemoryGame : () => { },
47+
'fibonacci': typeof initFibonacci !== 'undefined' ? initFibonacci : () => { },
48+
'progression-recognizer': typeof initProgressionRecognizer !== 'undefined' ? initProgressionRecognizer : () => { },
49+
'pascal-triangle': typeof initPascalTriangle !== 'undefined' ? initPascalTriangle : () => { },
50+
'armstrong': typeof initArmstrong !== 'undefined' ? initArmstrong : () => { },
51+
'calculator': typeof initCalculator !== 'undefined' ? initCalculator : () => { },
52+
'collatz': typeof initCollatz !== 'undefined' ? initCollatz : () => { },
53+
'prime-analyzer': typeof initPrimeAnalyzer !== 'undefined' ? initPrimeAnalyzer : () => { },
54+
'projectile-motion': typeof initProjectileMotion !== 'undefined' ? initProjectileMotion : () => { },
55+
'coordinate-polar-transform': typeof initCoordinatePolarTransform !== 'undefined' ? initCoordinatePolarTransform : () => { },
56+
'derivative-calculator': typeof initDerivativeCalculator !== 'undefined' ? initDerivativeCalculator : () => { },
57+
'morse-code': typeof initMorseCode !== 'undefined' ? initMorseCode : () => { },
58+
'tower-of-hanoi': typeof initTowerOfHanoi !== 'undefined' ? initTowerOfHanoi : () => { },
59+
'number-converter': typeof initNumberConverter !== 'undefined' ? initNumberConverter : () => { },
60+
'typing-speed-tester': typeof initTypingSpeedTester !== 'undefined' ? initTypingSpeedTester : () => { },
61+
'snake-game': typeof initSnakeGame !== 'undefined' ? initSnakeGame : () => { },
62+
'spot-the-difference': typeof initSpotTheDifference !== 'undefined' ? initSpotTheDifference : () => { },
63+
'whack-a-mole': typeof initWhackaMole !== 'undefined' ? initWhackaMole : () => { },
6464
};
65-
65+
6666
if (initializers[projectName]) {
6767
initializers[projectName]();
6868
}
@@ -78,7 +78,7 @@ function initializeProject(projectName) {
7878
// modular design patterns.
7979
//
8080
// If you are looking to modify, fix, or understand how a specific project works:
81-
// 1. Do NOT add game loops, event listeners, or variables to this file.
81+
// 1. Do NOT add game logics, event listeners, or variables to this file.
8282
// 2. Open the dedicated script file under the 'js/projects/' directory.
8383
// - e.g., For Rock Paper Scissors, see: js/projects/rock-paper-scissor.js
8484
// - e.g., For FLAMES, see: js/projects/flames.js

0 commit comments

Comments
 (0)