├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── main.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md └── src ├── 07-color-swatches ├── begin │ ├── begin.css │ ├── begin.js │ └── index.html └── end │ ├── end.css │ ├── end.js │ └── index.html ├── 08-movie-api ├── begin │ ├── begin.css │ ├── begin.js │ └── index.html └── end │ ├── end.css │ ├── end.js │ └── index.html ├── 09-blog-post-url ├── begin │ ├── begin.js │ └── index.html └── end │ ├── end.js │ └── index.html ├── 10-matching-brackets ├── begin │ ├── begin.js │ └── index.html └── end │ ├── end.js │ └── index.html ├── 11-binary-to-decimal ├── begin │ ├── begin.js │ └── index.html └── end │ ├── end.js │ └── index.html └── 12-responsive-layout ├── begin ├── begin.css └── index.html └── end ├── end.css └── index.html /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Codeowners for these exercise files: 2 | # * (asterisk) deotes "all files and folders" 3 | # Example: * @producer @instructor 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ## Issue Overview 9 | 10 | 11 | ## Describe your environment 12 | 13 | 14 | ## Steps to Reproduce 15 | 16 | 1. 17 | 2. 18 | 3. 19 | 4. 20 | 21 | ## Expected Behavior 22 | 23 | 24 | ## Current Behavior 25 | 26 | 27 | ## Possible Solution 28 | 29 | 30 | ## Screenshots / Video 31 | 32 | 33 | ## Related Issues 34 | 35 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Copy To Branches 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | copy-to-branches: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v2 9 | with: 10 | fetch-depth: 0 11 | - name: Copy To Branches Action 12 | uses: planetoftheweb/copy-to-branches@v1 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | .tmp 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Contribution Agreement 3 | ====================== 4 | 5 | This repository does not accept pull requests (PRs). All pull requests will be closed. 6 | 7 | However, if any contributions (through pull requests, issues, feedback or otherwise) are provided, as a contributor, you represent that the code you submit is your original work or that of your employer (in which case you represent you have the right to bind your employer). By submitting code (or otherwise providing feedback), you (and, if applicable, your employer) are licensing the submitted code (and/or feedback) to LinkedIn and the open source community subject to the BSD 2-Clause license. 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LinkedIn Learning Exercise Files License Agreement 2 | ================================================== 3 | 4 | This License Agreement (the "Agreement") is a binding legal agreement 5 | between you (as an individual or entity, as applicable) and LinkedIn 6 | Corporation (“LinkedIn”). By downloading or using the LinkedIn Learning 7 | exercise files in this repository (“Licensed Materials”), you agree to 8 | be bound by the terms of this Agreement. If you do not agree to these 9 | terms, do not download or use the Licensed Materials. 10 | 11 | 1. License. 12 | - a. Subject to the terms of this Agreement, LinkedIn hereby grants LinkedIn 13 | members during their LinkedIn Learning subscription a non-exclusive, 14 | non-transferable copyright license, for internal use only, to 1) make a 15 | reasonable number of copies of the Licensed Materials, and 2) make 16 | derivative works of the Licensed Materials for the sole purpose of 17 | practicing skills taught in LinkedIn Learning courses. 18 | - b. Distribution. Unless otherwise noted in the Licensed Materials, subject 19 | to the terms of this Agreement, LinkedIn hereby grants LinkedIn members 20 | with a LinkedIn Learning subscription a non-exclusive, non-transferable 21 | copyright license to distribute the Licensed Materials, except the 22 | Licensed Materials may not be included in any product or service (or 23 | otherwise used) to instruct or educate others. 24 | 25 | 2. Restrictions and Intellectual Property. 26 | - a. You may not to use, modify, copy, make derivative works of, publish, 27 | distribute, rent, lease, sell, sublicense, assign or otherwise transfer the 28 | Licensed Materials, except as expressly set forth above in Section 1. 29 | - b. Linkedin (and its licensors) retains its intellectual property rights 30 | in the Licensed Materials. Except as expressly set forth in Section 1, 31 | LinkedIn grants no licenses. 32 | - c. You indemnify LinkedIn and its licensors and affiliates for i) any 33 | alleged infringement or misappropriation of any intellectual property rights 34 | of any third party based on modifications you make to the Licensed Materials, 35 | ii) any claims arising from your use or distribution of all or part of the 36 | Licensed Materials and iii) a breach of this Agreement. You will defend, hold 37 | harmless, and indemnify LinkedIn and its affiliates (and our and their 38 | respective employees, shareholders, and directors) from any claim or action 39 | brought by a third party, including all damages, liabilities, costs and 40 | expenses, including reasonable attorneys’ fees, to the extent resulting from, 41 | alleged to have resulted from, or in connection with: (a) your breach of your 42 | obligations herein; or (b) your use or distribution of any Licensed Materials. 43 | 44 | 3. Open source. This code may include open source software, which may be 45 | subject to other license terms as provided in the files. 46 | 47 | 4. Warranty Disclaimer. LINKEDIN PROVIDES THE LICENSED MATERIALS ON AN “AS IS” 48 | AND “AS AVAILABLE” BASIS. LINKEDIN MAKES NO REPRESENTATION OR WARRANTY, 49 | WHETHER EXPRESS OR IMPLIED, ABOUT THE LICENSED MATERIALS, INCLUDING ANY 50 | REPRESENTATION THAT THE LICENSED MATERIALS WILL BE FREE OF ERRORS, BUGS OR 51 | INTERRUPTIONS, OR THAT THE LICENSED MATERIALS ARE ACCURATE, COMPLETE OR 52 | OTHERWISE VALID. TO THE FULLEST EXTENT PERMITTED BY LAW, LINKEDIN AND ITS 53 | AFFILIATES DISCLAIM ANY IMPLIED OR STATUTORY WARRANTY OR CONDITION, INCLUDING 54 | ANY IMPLIED WARRANTY OR CONDITION OF MERCHANTABILITY OR FITNESS FOR A 55 | PARTICULAR PURPOSE, AVAILABILITY, SECURITY, TITLE AND/OR NON-INFRINGEMENT. 56 | YOUR USE OF THE LICENSED MATERIALS IS AT YOUR OWN DISCRETION AND RISK, AND 57 | YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGE THAT RESULTS FROM USE OF THE 58 | LICENSED MATERIALS TO YOUR COMPUTER SYSTEM OR LOSS OF DATA. NO ADVICE OR 59 | INFORMATION, WHETHER ORAL OR WRITTEN, OBTAINED BY YOU FROM US OR THROUGH OR 60 | FROM THE LICENSED MATERIALS WILL CREATE ANY WARRANTY OR CONDITION NOT 61 | EXPRESSLY STATED IN THESE TERMS. 62 | 63 | 5. Limitation of Liability. LINKEDIN SHALL NOT BE LIABLE FOR ANY INDIRECT, 64 | INCIDENTAL, SPECIAL, PUNITIVE, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING 65 | BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER 66 | INTANGIBLE LOSSES . IN NO EVENT WILL LINKEDIN'S AGGREGATE LIABILITY TO YOU 67 | EXCEED $100. THIS LIMITATION OF LIABILITY SHALL: 68 | - i. APPLY REGARDLESS OF WHETHER (A) YOU BASE YOUR CLAIM ON CONTRACT, TORT, 69 | STATUTE, OR ANY OTHER LEGAL THEORY, (B) WE KNEW OR SHOULD HAVE KNOWN ABOUT 70 | THE POSSIBILITY OF SUCH DAMAGES, OR (C) THE LIMITED REMEDIES PROVIDED IN THIS 71 | SECTION FAIL OF THEIR ESSENTIAL PURPOSE; AND 72 | - ii. NOT APPLY TO ANY DAMAGE THAT LINKEDIN MAY CAUSE YOU INTENTIONALLY OR 73 | KNOWINGLY IN VIOLATION OF THESE TERMS OR APPLICABLE LAW, OR AS OTHERWISE 74 | MANDATED BY APPLICABLE LAW THAT CANNOT BE DISCLAIMED IN THESE TERMS. 75 | 76 | 6. Termination. This Agreement automatically terminates upon your breach of 77 | this Agreement or termination of your LinkedIn Learning subscription. On 78 | termination, all licenses granted under this Agreement will terminate 79 | immediately and you will delete the Licensed Materials. Sections 2-7 of this 80 | Agreement survive any termination of this Agreement. LinkedIn may discontinue 81 | the availability of some or all of the Licensed Materials at any time for any 82 | reason. 83 | 84 | 7. Miscellaneous. This Agreement will be governed by and construed in 85 | accordance with the laws of the State of California without regard to conflict 86 | of laws principles. The exclusive forum for any disputes arising out of or 87 | relating to this Agreement shall be an appropriate federal or state court 88 | sitting in the County of Santa Clara, State of California. If LinkedIn does 89 | not act to enforce a breach of this Agreement, that does not mean that 90 | LinkedIn has waived its right to enforce this Agreement. The Agreement does 91 | not create a partnership, agency relationship, or joint venture between the 92 | parties. Neither party has the power or authority to bind the other or to 93 | create any obligation or responsibility on behalf of the other. You may not, 94 | without LinkedIn’s prior written consent, assign or delegate any rights or 95 | obligations under these terms, including in connection with a change of 96 | control. Any purported assignment and delegation shall be ineffective. The 97 | Agreement shall bind and inure to the benefit of the parties, their respective 98 | successors and permitted assigns. If any provision of the Agreement is 99 | unenforceable, that provision will be modified to render it enforceable to the 100 | extent possible to give effect to the parties’ intentions and the remaining 101 | provisions will not be affected. This Agreement is the only agreement between 102 | you and LinkedIn regarding the Licensed Materials, and supersedes all prior 103 | agreements relating to the Licensed Materials. 104 | 105 | Last Updated: March 2019 106 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2022 LinkedIn Corporation 2 | All Rights Reserved. 3 | 4 | Licensed under the LinkedIn Learning Exercise File License (the "License"). 5 | See LICENSE in the project root for license information. 6 | 7 | Please note, this project may automatically load third party code from external 8 | repositories (for example, NPM modules, Composer packages, or other dependencies). 9 | If so, such third party code may be subject to other license terms than as set 10 | forth above. In addition, such third party code may also depend on and load 11 | multiple tiers of dependencies. Please review the applicable licenses of the 12 | additional dependencies. 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ace Your Web Developer Interview 2 | This is the repository for the LinkedIn Learning course Ace Your Web Developer Interview. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | ![Ace Your Web Developer Interview][lil-thumbnail-url] 5 | 6 | You know you’re a great developer for the job, but how do you prove it to your interviewers? It can be challenging to feel confident in web development technical interviews. In this course, instructor Emma Bostian equips you with the problem solving skills you need to ace your web developer interviews. Emma doesn’t focus on teaching computer science or web development topics. Instead, she teaches you how to use the skills you already have to solve technical problems. Emma uses a series of challenges to give you real-world practice and walk you through how to ask clarifying questions, architect your first solution, optimize your code, and test for edge cases. 7 | 8 | 9 | ### Instructor 10 | 11 | Emma Bostian 12 | 13 | Software Engineer 14 | 15 | 16 | 17 | Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/emma-bostian). 18 | 19 | [lil-course-url]: https://www.linkedin.com/learning/ace-your-web-developer-interview 20 | [lil-thumbnail-url]: https://cdn.lynda.com/course/3011844/3011844-1645119863916-16x9.jpg 21 | -------------------------------------------------------------------------------- /src/07-color-swatches/begin/begin.css: -------------------------------------------------------------------------------- 1 | /* 2 | box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); 3 | font-family: "Arial", sans-serif; 4 | font-weight: bold; 5 | */ 6 | -------------------------------------------------------------------------------- /src/07-color-swatches/begin/begin.js: -------------------------------------------------------------------------------- 1 | const swatchData = [ 2 | { 3 | hex: "#fde2e4", 4 | rgb: "rgb(253, 226, 228)", 5 | }, 6 | { 7 | hex: "#e2ece9", 8 | rgb: "rgb(226, 236, 233)", 9 | }, 10 | { 11 | hex: "#bee1e6", 12 | rgb: "rgb(190, 225, 230)", 13 | }, 14 | { 15 | hex: "#cddafd", 16 | rgb: "rgb(205, 218, 253)", 17 | }, 18 | ]; 19 | -------------------------------------------------------------------------------- /src/07-color-swatches/begin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Color Swatches 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/07-color-swatches/end/end.css: -------------------------------------------------------------------------------- 1 | /* 2 | box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); 3 | font-family: "Arial", sans-serif; 4 | font-weight: bold; 5 | */ 6 | #swatch-container { 7 | display: flex; 8 | justify-content: space-evenly; 9 | flex-wrap: wrap; 10 | row-gap: 16px; 11 | } 12 | 13 | .swatch-wrapper { 14 | border-radius: 4px; 15 | max-width: 200px; 16 | transition: box-shadow 0.1s linear; 17 | cursor: pointer; 18 | } 19 | 20 | .swatch-wrapper:hover, 21 | .swatch-wrapper:focus { 22 | box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); 23 | } 24 | 25 | .color-wrapper { 26 | height: 120px; 27 | border-radius: 4px 4px 0px 0px; 28 | } 29 | 30 | .metadata-wrapper { 31 | background: #f2f2f2; 32 | border-radius: 0px 0px 4px 4px; 33 | padding: 16px; 34 | font-family: "Arial", sans-serif; 35 | font-weight: bold; 36 | } 37 | -------------------------------------------------------------------------------- /src/07-color-swatches/end/end.js: -------------------------------------------------------------------------------- 1 | const swatchData = [ 2 | { 3 | hex: "#fde2e4", 4 | rgb: "rgb(253, 226, 228)", 5 | }, 6 | { 7 | hex: "#e2ece9", 8 | rgb: "rgb(226, 236, 233)", 9 | }, 10 | { 11 | hex: "#bee1e6", 12 | rgb: "rgb(190, 225, 230)", 13 | }, 14 | { 15 | hex: "#cddafd", 16 | rgb: "rgb(205, 218, 253)", 17 | }, 18 | ]; 19 | 20 | function constructSwatches(swatchData) { 21 | const swatchContainer = document.querySelector("#swatch-container"); 22 | 23 | swatchData.forEach((swatch) => { 24 | swatchContainer.appendChild(generateSwatch(swatch)); 25 | }); 26 | } 27 | 28 | function generateSwatch(swatch) { 29 | const swatchWrapper = document.createElement("div"); 30 | swatchWrapper.className = "swatch-wrapper"; 31 | 32 | const colorWrapper = document.createElement("div"); 33 | colorWrapper.className = "color-wrapper"; 34 | colorWrapper.style.background = swatch.hex; 35 | 36 | const metadataWrapper = document.createElement("div"); 37 | metadataWrapper.className = "metadata-wrapper"; 38 | 39 | const hexParagraph = document.createElement("p"); 40 | hexParagraph.innerText = swatch.hex; 41 | 42 | const rgbParagraph = document.createElement("p"); 43 | rgbParagraph.innerText = swatch.rgb; 44 | 45 | metadataWrapper.appendChild(hexParagraph); 46 | metadataWrapper.appendChild(rgbParagraph); 47 | 48 | swatchWrapper.appendChild(colorWrapper); 49 | swatchWrapper.appendChild(metadataWrapper); 50 | 51 | return swatchWrapper; 52 | } 53 | 54 | constructSwatches(swatchData); 55 | -------------------------------------------------------------------------------- /src/07-color-swatches/end/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Color Swatches 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/08-movie-api/begin/begin.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinkedInLearning/ace-your-web-developer-interview-3011844/157302330d3e4835ad5e7ff944a6c9f0c34977f3/src/08-movie-api/begin/begin.css -------------------------------------------------------------------------------- /src/08-movie-api/begin/begin.js: -------------------------------------------------------------------------------- 1 | /* 2 | URL: "https://imdb8.p.rapidapi.com/title/find?q=Star%20Wars" 3 | "x-rapidapi-host": "imdb8.p.rapidapi.com" 4 | "x-rapidapi-key": "7dc4683476msh81675cd0e90bd2bp17842ejsn3357aee41f0a" 5 | */ 6 | -------------------------------------------------------------------------------- /src/08-movie-api/begin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Movie API 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/08-movie-api/end/end.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | font-family: "Impact"; 3 | } 4 | 5 | #poster-container { 6 | display: flex; 7 | justify-content: space-around; 8 | flex-wrap: wrap; 9 | } 10 | 11 | .movie-container { 12 | border: 2px solid gray; 13 | padding: 24px; 14 | width: 300px; 15 | display: flex; 16 | flex-direction: column; 17 | align-items: center; 18 | text-align: center; 19 | } 20 | -------------------------------------------------------------------------------- /src/08-movie-api/end/end.js: -------------------------------------------------------------------------------- 1 | /* 2 | URL: "https://imdb8.p.rapidapi.com/title/find?q=Star%20Wars" 3 | "x-rapidapi-host": "imdb8.p.rapidapi.com" 4 | "x-rapidapi-key": "7dc4683476msh81675cd0e90bd2bp17842ejsn3357aee41f0a" 5 | */ 6 | 7 | fetch("https://imdb8.p.rapidapi.com/title/find?q=Star%20Wars", { 8 | method: "GET", 9 | headers: { 10 | "x-rapidapi-host": "imdb8.p.rapidapi.com", 11 | "x-rapidapi-key": "7dc4683476msh81675cd0e90bd2bp17842ejsn3357aee41f0a", 12 | }, 13 | }) 14 | .then(async (response) => { 15 | const { results } = await response.json(); 16 | const formattedResults = []; 17 | let currentIndex = 0; 18 | 19 | while (formattedResults.length < 5) { 20 | let currentResult = results[currentIndex]; 21 | if (!currentResult.title) { 22 | currentIndex++; 23 | continue; 24 | } 25 | 26 | const { 27 | title, 28 | year, 29 | image: { url }, 30 | } = currentResult; 31 | formattedResults.push({ 32 | title, 33 | year, 34 | image: url, 35 | }); 36 | currentIndex++; 37 | } 38 | makeMoviePoster(formattedResults); 39 | }) 40 | .catch((err) => { 41 | throw new Error(err); 42 | }); 43 | 44 | function makeMoviePoster(movies) { 45 | const posterContainer = document.querySelector("#poster-container"); 46 | movies.forEach(({ title, year, image }) => { 47 | const movieContainer = document.createElement("div"); 48 | movieContainer.classList.add("movie-container"); 49 | 50 | const poster = document.createElement("img"); 51 | poster.src = image; 52 | poster.alt = title; 53 | poster.width = 200; 54 | poster.height = 300; 55 | movieContainer.appendChild(poster); 56 | 57 | const titleNode = document.createElement("h1"); 58 | titleNode.textContent = `${title} - ${year}`; 59 | movieContainer.appendChild(titleNode); 60 | 61 | posterContainer.appendChild(movieContainer); 62 | }); 63 | } 64 | -------------------------------------------------------------------------------- /src/08-movie-api/end/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Movie API 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/09-blog-post-url/begin/begin.js: -------------------------------------------------------------------------------- 1 | /* 2 | Punctuation to remove 3 | [!@#$%^&*()_+={}.,:'"/~`;[\[\]] 4 | */ 5 | 6 | function blogify(title) {} 7 | 8 | const blogs = [ 9 | "My Summer Studying Abroad!!!", 10 | "Emma's Favorite Books :)", 11 | "Best Stockholm restaurants in 2021", 12 | "There are a ton of spaces", 13 | 'This., -/ is #! an $ % ^ & * example ;: {} of a = -_ string with `~)() punctuation"', 14 | ]; 15 | 16 | blogs.forEach((blog) => console.log(blogify(blog))); 17 | -------------------------------------------------------------------------------- /src/09-blog-post-url/begin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Blog Post URL 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/09-blog-post-url/end/end.js: -------------------------------------------------------------------------------- 1 | /* 2 | Punctuation to remove 3 | [!@#$%^&*()_+={}.,:'"/~`;[\[\]] 4 | */ 5 | 6 | function blogify(title) { 7 | const urlBase = "https://www.myblog.com"; 8 | // Replace white space with hyphens 9 | const noSpaces = title.replace(/\s+/g, "-"); 10 | // Lowercase the entire string 11 | const lowercase = noSpaces.toLowerCase(); 12 | // Remove punctuation 13 | const noPunctuationRegex = /[!@#$%^&*()_+={}.,:'"/~`;[\[\]]/g; 14 | const noPunctuation = lowercase.replace(noPunctuationRegex, ""); 15 | 16 | // No consecutive hyphens 17 | const noConsecutiveHyphens = noPunctuation.replace(/[-]{2,}/g, "-"); 18 | 19 | // Remove trailing hyphen 20 | const noTrailingHyphen = noConsecutiveHyphens.replace(/-$/, ""); 21 | 22 | return `${urlBase}/${noTrailingHyphen}`; 23 | } 24 | 25 | const blogs = [ 26 | "My Summer Studying Abroad!!!", 27 | "Emma's Favorite Books :)", 28 | "Best Stockholm restaurants in 2021", 29 | "There are a ton of spaces", 30 | 'This., -/ is #! an $ % ^ & * example ;: {} of a = -_ string with `~)() punctuation"', 31 | ]; 32 | 33 | blogs.forEach((blog) => console.log(blogify(blog))); 34 | -------------------------------------------------------------------------------- /src/09-blog-post-url/end/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Blog Post URL 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/10-matching-brackets/begin/begin.js: -------------------------------------------------------------------------------- 1 | function matchingBrackets(str) {} 2 | 3 | console.log(`${matchingBrackets("[hello][world]")} should be true`); // true 4 | console.log(`${matchingBrackets("[hello]][world]")} should be false`); // false 5 | console.log(`${matchingBrackets("[hello][world][]")} should be true`); // true 6 | console.log(`${matchingBrackets("]hello]][world]")} should be false`); // false 7 | console.log(`${matchingBrackets("[[[as;dfi")} should be false`); // false 8 | -------------------------------------------------------------------------------- /src/10-matching-brackets/begin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Matching Brackets 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/10-matching-brackets/end/end.js: -------------------------------------------------------------------------------- 1 | function matchingBrackets(str) { 2 | const charArray = str.split(""); 3 | let counter = 0; 4 | for (let char of charArray) { 5 | if (char === "[") { 6 | counter++; 7 | } else if (char === "]") { 8 | if (counter <= 0) { 9 | return false; 10 | } else { 11 | counter--; 12 | } 13 | } 14 | } 15 | return counter === 0; 16 | } 17 | 18 | function matchingBracketsStack(str) { 19 | const charArray = str.split(""); 20 | 21 | // Top of the stack is the end of the array 22 | // stack.pop() to remove top item 23 | // stack.push() to add an item 24 | const stack = []; 25 | 26 | for (let char of charArray) { 27 | if (char === "[") { 28 | stack.push(char); 29 | } else if (char === "]") { 30 | if (stack.length > 0) { 31 | stack.pop(); 32 | } else { 33 | return false; 34 | } 35 | } 36 | } 37 | return stack.length === 0; 38 | } 39 | 40 | console.log(`${matchingBrackets("[hello][world]")} should be true`); // true 41 | console.log(`${matchingBrackets("[hello]][world]")} should be false`); // false 42 | console.log(`${matchingBrackets("[hello][world][]")} should be true`); // true 43 | console.log(`${matchingBrackets("]hello]][world]")} should be false`); // false 44 | console.log(`${matchingBrackets("[[[as;dfi")} should be false`); // false 45 | -------------------------------------------------------------------------------- /src/10-matching-brackets/end/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Matching Brackets 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/11-binary-to-decimal/begin/begin.js: -------------------------------------------------------------------------------- 1 | function binaryToDecimal(binary) {} 2 | 3 | console.log(binaryToDecimal("101010")); // 42 4 | console.log(binaryToDecimal("101100000")); // 352 5 | console.log(binaryToDecimal("1")); // 1 6 | console.log(binaryToDecimal("13298436")); // "13298436 is not a valid binary string" 7 | console.log(binaryToDecimal("abc")); // "abc is not a valid binary string" 8 | -------------------------------------------------------------------------------- /src/11-binary-to-decimal/begin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Binary To Decimal 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/11-binary-to-decimal/end/end.js: -------------------------------------------------------------------------------- 1 | function binaryToDecimal(binary) { 2 | const binaryRegex = new RegExp(/[01]+$/); 3 | if (!binaryRegex.test(binary)) { 4 | return `${binary} is not a valid binary string`; 5 | } 6 | 7 | let decimalTotal = 0; 8 | let power = binary.length - 1; 9 | let index = 0; 10 | 11 | while (power >= 0) { 12 | let char = binary.charAt(index); 13 | if (char === "1") { 14 | decimalTotal += Math.pow(2, power); 15 | } 16 | power--; 17 | index++; 18 | } 19 | 20 | return decimalTotal; 21 | } 22 | 23 | console.log(binaryToDecimal("101010")); // 42 24 | console.log(binaryToDecimal("101100000")); // 352 25 | console.log(binaryToDecimal("1")); // 1 26 | console.log(binaryToDecimal("13298436")); // "13298436 is not a valid binary string" 27 | console.log(binaryToDecimal("abc")); // "abc is not a valid binary string" 28 | -------------------------------------------------------------------------------- /src/11-binary-to-decimal/end/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Binary To Decimal 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/12-responsive-layout/begin/begin.css: -------------------------------------------------------------------------------- 1 | /* 2 | blue: #cddadf; 3 | red: #fde2e4; 4 | yellow: #fef1cf; 5 | green: #d0e9c8; 6 | purple: #ebcdfd; 7 | */ 8 | -------------------------------------------------------------------------------- /src/12-responsive-layout/begin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Responsive Layout 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/12-responsive-layout/end/end.css: -------------------------------------------------------------------------------- 1 | /* 2 | blue: #cddadf; 3 | red: #fde2e4; 4 | yellow: #fef1cf; 5 | green: #d0e9c8; 6 | purple: #ebcdfd; 7 | */ 8 | 9 | .container { 10 | display: flex; 11 | border: 2px solid black; 12 | flex-wrap: wrap; 13 | justify-content: space-between; 14 | padding: 16px; 15 | max-width: 160px; 16 | } 17 | 18 | .block { 19 | height: 60px; 20 | min-width: 60px; 21 | margin: 8px; 22 | flex-basis: 100%; 23 | } 24 | 25 | .block--blue { 26 | background: #cddadf; 27 | } 28 | 29 | .block--red { 30 | background: #fde2e4; 31 | } 32 | 33 | .block--yellow { 34 | background: #fef1cf; 35 | } 36 | 37 | .block--green { 38 | background: #d0e9c8; 39 | } 40 | 41 | .block--purple { 42 | background: #ebcdfd; 43 | } 44 | 45 | @media (min-width: 700px) { 46 | .container { 47 | max-width: 280px; 48 | } 49 | 50 | .block--red, 51 | .block--yellow, 52 | .block--green { 53 | flex-basis: calc(33% - 16px); 54 | } 55 | } 56 | 57 | @media (min-width: 1000px) { 58 | .container { 59 | min-width: 360px; 60 | } 61 | 62 | .block { 63 | flex-basis: auto; 64 | } 65 | 66 | .block--blue { 67 | flex-basis: 50%; 68 | } 69 | 70 | .block--green { 71 | flex-basis: calc(30% - 16px); 72 | } 73 | 74 | .block--purple { 75 | flex-basis: calc(70% - 16px); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/12-responsive-layout/end/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Responsive Layout 7 | 8 | 9 | 10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 | --------------------------------------------------------------------------------