This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const alpha = { | |
| budget: 63000000, | |
| director: 'Wachowskis', | |
| title: 'The Matrix' | |
| } | |
| const beta = { | |
| budget: 7200000, | |
| director: 'Coppola', | |
| title: 'The Godfather' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const theHobbit = { | |
| author: 'Tolkien', | |
| protagonist: 'Bilbo', | |
| pages: 300 | |
| } | |
| const watchmen = { | |
| author: 'Moore', | |
| protagonist: 'Rorschach', | |
| pages: 450 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Questions | |
| ## 1. JavaScript | |
| Explain the concept of closures in JavaScript and provide a scenario where they might cause memory leaks if not handled properly. | |
| ## 2. TypeScript | |
| How would you type a function that accepts either a string or number and returns the same type that was passed in? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Issues | |
| ## Serious Security Concern | |
| 1. Private variables are exposed in .env.example | |
| 1. MONDGODB_URI (db password) | |
| 2. JWT_SECRET | |
| 3. AWS_SECRET_ACCESS_KEY_ID | |
| 4. STRIPE_SECRET_KEY / STRIPE_WEBHOOK_SECRET | |
| 5. SENDGRID_API_KEY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Questions | |
| ## JavaScript | |
| ### Question 1 | |
| ```javascript | |
| async function fetchUser(id) { | |
| const response = await fetch(`/api/users/${id}`); | |
| const user = await response.json(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { IdentifyUserInput, identifyUserInputSchema, IdentifyUserOutput, identifyUserOutputSchema, SubmitCampaignInput, submitCampaignInputSchema, SubmitCampaignOutput, submitCampaignOutputSchema } from "../types"; | |
| export async function callIdentifyUser (input:IdentifyUserInput): Promise<IdentifyUserOutput> { | |
| const parsedInput = identifyUserInputSchema.parse(input) | |
| const body = JSON.stringify(parsedInput) | |
| const response = await fetch('/api/identifyUser', { | |
| method: 'POST', | |
| body | |
| }) | |
| if (!response.ok) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Van <Cargo> { | |
| destination: string | |
| cargo: Cargo | |
| } | |
| const bakeryVan = { | |
| destination: 'bakery', | |
| cargo: 5 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function openMine () { | |
| let diamonds = 21 | |
| function dig (getDug: (remaining: number) => number) { | |
| const dug = getDug(diamonds) | |
| diamonds -= dug | |
| console.log('diamonds', diamonds) | |
| return dug | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let diamonds: number = 10 | |
| function dig (getDug: (remaining: number) => number) { | |
| let dug = getDug(diamonds) | |
| diamonds -= dug | |
| return dug | |
| } | |
| function getOne () { | |
| return 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const form = document.getElementById('productForm') | |
| form.addEventListener('submit', async (event) => { | |
| event.preventDefault() | |
| const name = document.getElementById('pname') | |
| const price = document.getElementById('price') | |
| const units = document.getElementById('units') | |
| const description = document.getElementById('desc') | |
| const isAvailable = document.getElementById('instock') | |
| const category = document.getElementById('category') |