diff --git a/Programmig test.docx b/Programmig test.docx new file mode 100644 index 0000000..7b2614f Binary files /dev/null and b/Programmig test.docx differ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..881559a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,52 @@ +{ + "name": "AP Computer Science Principles", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "tsc": "^2.0.4" + }, + "devDependencies": { + "@types/node": "^24.5.1", + "typescript": "^5.9.2" + } + }, + "node_modules/@types/node": { + "version": "24.5.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.5.1.tgz", + "integrity": "sha512-/SQdmUP2xa+1rdx7VwB9yPq8PaKej8TD5cQ+XfKDPWWC+VDJU4rvVVagXqKUzhKjtFoNA8rXDJAkCxQPAe00+Q==", + "dev": true, + "dependencies": { + "undici-types": "~7.12.0" + } + }, + "node_modules/tsc": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz", + "integrity": "sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q==", + "bin": { + "tsc": "bin/tsc" + } + }, + "node_modules/typescript": { + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", + "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "7.12.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.12.0.tgz", + "integrity": "sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..45a64ae --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "devDependencies": { + "@types/node": "^24.5.1", + "typescript": "^5.9.2" + }, + "dependencies": { + "tsc": "^2.0.4" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0771a3a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,44 @@ +{ + // Visit https://aka.ms/tsconfig to read more about this file + "compilerOptions": { + // File Layout + // "rootDir": "./src", + // "outDir": "./dist", + + // Environment Settings + // See also https://aka.ms/tsconfig/module + "module": "nodenext", + "target": "esnext", + "types": [], + // For nodejs: + "lib": ["ES2018", "dom"], + // "types": ["node"], + // and npm install -D @types/node + + // Other Outputs + "sourceMap": true, + "declaration": true, + "declarationMap": true, + + // Stricter Typechecking Options + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + + // Style Options + // "noImplicitReturns": true, + // "noImplicitOverride": true, + // "noUnusedLocals": true, + // "noUnusedParameters": true, + // "noFallthroughCasesInSwitch": true, + // "noPropertyAccessFromIndexSignature": true, + + // Recommended Options + "strict": true, + "jsx": "react-jsx", + "verbatimModuleSyntax": true, + "isolatedModules": true, + "noUncheckedSideEffectImports": true, + "moduleDetection": "force", + "skipLibCheck": true, + } +} diff --git a/typescriptisbetter.js b/typescriptisbetter.js new file mode 100644 index 0000000..e2ff939 --- /dev/null +++ b/typescriptisbetter.js @@ -0,0 +1,50 @@ +// humberto mundo +var animals = ["Zebra", "Koala", "Lion", "Elephant", "Eagle", "Cat", "Eagle"]; +// Write a function named getLocation(list, word) to return the location of the parameter word +// in the array list, if it exist, returns -1 if it does not exists +function getLocation(list, word) { + return list.indexOf(word); +} +// Write a function named getLongest(list) which needs to return the longest string in array +// parameter array +function getLongest(array) { + if (!array) + return "provide a array"; + var long = array[0]; // init w/ first element + for (var i = 1; i < array.length; i++) { + // const element = list[i]; + if (array[i].length > long.length) { // this is why i love and hate typescript :3 + long = array[i]; + } + } + return long; +} +// extra cus y not +function getShortest(list) { + if (!list) + return "i need array >:("; + var short = list[0]; + for (var i = 1; i < list.length; i++) { + if (list[i].length < short.length) { + short = list[i]; + } + } + return short; +} +// Write a function named spellBackward(list, word) which it needs to return parameter word +// spell backwards if it exist in array list, otherwise it return word does not exist. +function spellBackward(list, word) { + if (!list.includes(word)) + return "word does not exist"; + return word.split("").reverse().join(""); +} +//write the rest of the code here +console.log(getLocation(animals, "Eagle")); // uhhhh 4 +console.log(getLocation(animals, "cat")); // should return -1 since its Cat not cat +console.log(); // spacers +console.log(getLongest(animals)); // Elephant +console.log(getShortest(animals)); // Cat +console.log(); // spacers +// i am the best programmer in the world +console.log(spellBackward(animals, "Eagle")); // should return elgaE +console.log(spellBackward(animals, "cat")); // should return "word does not exist"