<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by k white - writing about learning on Medium]]></title>
        <description><![CDATA[Stories by k white - writing about learning on Medium]]></description>
        <link>https://medium.com/@k-atwhite?source=rss-cc7ec433d02d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nSh_DAN6b95wqMZyb5hv0A.jpeg</url>
            <title>Stories by k white - writing about learning on Medium</title>
            <link>https://medium.com/@k-atwhite?source=rss-cc7ec433d02d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:10:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@k-atwhite/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Questions and Answers]]></title>
            <link>https://k-atwhite.medium.com/questions-and-answers-fe-interview-prep-7e7e059ee2d?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e7e059ee2d</guid>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Wed, 27 Oct 2021 22:23:59 GMT</pubDate>
            <atom:updated>2021-10-28T01:50:15.102Z</atom:updated>
            <content:encoded><![CDATA[<h4>Front End Interview Questions</h4><h4>Localizing means translating a software into a local language and culture.</h4><ul><li>Find out who your audience is / define your audience</li><li>Build a relationship with translators</li><li>Ensure you localize the WHOLE experience, not just parts</li><li>Don’t forget about measurements, currency, idioms, etc</li></ul><p><strong>Tell me two advantages of testing your code.</strong></p><ul><li>Solid documentation</li><li>Find errors before they happen</li><li>Seamless deployment with a big team — integrating CI</li></ul><p><strong>Name three strategies for fixing cross-browser inconsistencies.</strong></p><ul><li>HTML viewport metatag</li><li>CSS flexbox and grid</li><li>HTML + CSS validation tools</li></ul><p>The point of this question is that consistency matters! Your app should have the same experience everywhere.</p><p><strong>What are some tools and strategies you use to prevent shipping unstable code to production?</strong></p><ul><li>Testing</li><li>Solid GH Projects</li><li>Git workflow</li><li>Continuous Integration</li><li>Continuous Deployment</li></ul><p><strong>What factors influence whether you’ll take a progressive enhancement vs. graceful degradation approach to building an application?</strong></p><p>Progressive Enhancement: establish a basic level of user experience that all browsers provide, but then build more advanced functionality for browsers that can handle it</p><p>Graceful Degradation: Building functionality to provide a certain level of experience, but offer less on older browsers</p><p><strong>Define the term ‘MVC’ and explain how an application is architected when following MVC patterns.</strong></p><ul><li>MODEL — VIEW — CONTROLLER</li><li>Model: Data model, data and logic</li><li>View: UI logic</li><li>Controller: Interface between model and view</li></ul><p><strong>What does CORS stand for and what issue does it address?</strong></p><ul><li>Cross Origin Resource Sharing</li><li>Essentially a security feature to ensure approved browsers get approved info</li></ul><p><strong>In as much detail as possible, describe the request-response cycle.</strong></p><p><strong>Tell me 3 new features of CSS3.</strong></p><ul><li>Opacity</li><li>More Web-Safe fonts</li><li>Attribute Selectors (rather than just IDs and Classes)</li></ul><p><strong>Can you describe what responsive design is to you and how you would implement it?</strong></p><ul><li>A principle of good web design that ensures a page looks good on all screen sizes. The app itself is response, it adjusts!</li></ul><p><strong>What’s the difference between display: inline and display: inline-block?</strong></p><ul><li>Block: Takes up a whole line</li><li>Inline: Shares the line</li></ul><h4>What is a pseudo class? What are they used for?</h4><ul><li>A keyword on a selector that is more specific. Ex :hover</li></ul><p><strong>Describe z-index and how stacking context is formed.</strong></p><ul><li>I understand this via my GIS background. It’s the third axis, and creates dimensionality. A model is on the Z axis</li></ul><p><strong>Why is it, in general, a good idea to leave the global scope of a website as-is and never touch it?f</strong></p><ul><li>Fragility! Their value can be changed by any function and that ain’t good.</li></ul><h4>What does event bubbling or event propagation mean?</h4><ul><li>The events that happen to inner elements “bubble up” through parent elements.</li></ul><h4>What’s the difference between undefined and null</h4><ul><li>Null is no value, undefined means even less. Like we don’t know what this should even be. Null is on purpose. Undefined is usually not.</li></ul><h4>In as much detail as possible, explain how JSON Web Tokens work.</h4><ul><li>Header</li><li>Payload</li><li>Strucutre</li><li>It’s a standard way to write an access token and send info securely</li></ul><h4>What is Ajax?</h4><ul><li>Ajax is not a technology, but a concept. It’s a set of techniques that use client side technology to create asynchronous web apps</li><li>It separates the data layer from the interface</li></ul><h4>What is “use strict”? What are the advantages and disadvantages to using it?</h4><ul><li>Define that JS should be executed in “strict mode” — you cannot use undeclared variables.</li></ul><p><strong>Explain why the following doesn’t work as an IIFE: function foo(){ }();. What needs to be changed to properly make it an IIFE? Why?</strong></p><ul><li>IIFE: Immediately invoked function expression OR self executing function</li></ul><p>What are the pros and cons of using Promises instead of callbacks?</p><ul><li>Promises Pros: integrated error handling, readability</li><li>Callback Pros: only one object can be returned</li></ul><h4>What is a closure, and how/why would you use one?</h4><ul><li>Frequently used in JS for object data privacy in event handlers/callback functions.</li><li>Gives you access to outer function’s scope from an inner function</li><li>They are created every time a function is created</li><li>Ex. defining a function inside of a funciton</li><li>What advantages does React offer? What about disadvantages?</li></ul><h4>Why is it generally a good idea to position CSS &lt;link&gt;s between &lt;head&gt;&lt;/head&gt; and JS &lt;script&gt;s just before &lt;/body&gt;? Do you know any exceptions?</h4><ul><li>B/c JS reads line by line — it parses and executes on the spot</li><li>Being at the botton helps the page load more fully and faster</li></ul><h4>In an HTML file, what does the ‘doctype’ keyword do?</h4><ul><li>It simple tells the browser what to expect!</li></ul><p>Give an example of a self-closing HTML tag.</p><ul><li>&lt;input /&gt;</li><li>&lt;image /&gt;</li></ul><h4>What’s the difference between window.onload and onDocumentReady</h4><ul><li>Ready occurrs after HTML document has been loaded = specific to JQuery</li><li>Onload occurs when all content has been loaded</li></ul><h4>Give an example of an element that is considered a ‘block-level’ element? An example of an inline element? What’s the difference between block-level and inline elements?</h4><ul><li>Block-level: &lt;div&gt;</li><li>Inline: &lt;span&gt;</li></ul><h4>What could we use instead of &lt;b&gt; tags for bold and &lt;i&gt; tags for italics to make our HTML more semantic?</h4><ul><li>Lots of better examples exist for improved accessibility / readability</li><li>&lt;em&gt; emphasis</li><li>&lt;strong&gt; importance</li><li>&lt;cite&gt; name of work</li><li>&lt;dfn&gt; definition</li></ul><h4>What is the purpose of article, section, header and footer tags? Please explain with an example and why we should not use divs.</h4><ul><li>In an effort ot write more “semantic”, ie specific, THNL, there are more container options</li></ul><h4>What are HTML data attributes?</h4><ul><li>These are like object properties, for elements. Class, Id, source, etc</li></ul><h4>What is the event loop?</h4><ul><li>JavaScripts concurrency model</li><li>Call Stack: keeps track of all operations to be executed</li><li>Queue: Send in new functions for processing</li></ul><h4>What are some popular NodeJS Modules?</h4><ul><li>Webpack — for compiling</li><li>Linters</li><li>Express</li></ul><h4>What is the concept of state in React?</h4><ul><li>State is the holder of truth. This is where we pill information to display to the user and to mutate. It is opposed to “props”, which are baskets that carry info (often from state) where the info needs to be</li></ul><h4>What is the virtual DOM in React?</h4><ul><li>Document Object Model:</li><li>This is an abstract representation of the DOM. In React, it’s purpose is to be a point of comparison against the “real” DOM. To determine if any changes have been made and need to be re-rendered.</li></ul><h4>How is an array different from an object?</h4><ul><li>Arrays are ordered lists — but they are object like! The index number is the property.</li><li>Objects is a list of name-value pairs.</li><li>You can access the information differently. Access an object with strings for example, rather than the index</li></ul><h4>What is the DOM? How is the virtual dom different?</h4><ul><li>Document Object Model:</li></ul><h4>What does npm eject do?</h4><ul><li>If you are unsatisfied, it removes ever build dependency</li></ul><h4>What does npm build do?</h4><ul><li>npm run build does nothing unless you specify what &quot;build&quot; does in your package.json file. It lets you perform any necessary building/prep tasks for your project, prior to it being used in another project</li></ul><h4>How do you make sure your project meets the requirements you have received?</h4><ul><li>Testing, User Studies, PM tools</li></ul><h4>How does json work?</h4><ul><li>JavaScript Object Notation</li><li>a way of representing data LIKE JS objects</li><li>used to send data</li><li>can be used independently from JS!</li><li>parse()</li><li>stringify()</li></ul><h4>What is a restful api?</h4><ul><li>REST — a set of architectural constraints</li></ul><h4>What is a callback function?</h4><ul><li>A callback function is a function passed into another function as an argument, which is then <strong>invoked inside the outer function to complete some kind of routine or action</strong>.</li><li>It’s a function I pass into another function — for my purproses, it’s usually something I want to do later</li><li>Example — passing an event into an mouse event like onClick</li></ul><h4>What is a react component?</h4><ul><li>A modular building block of the React framework. Now that i’m working with hooks — I’m using “functional components” which are really just functions.</li><li>They FEEL like classes to me — because they can have methods and variables and can be reused (modular). But a component can be rendered directly.</li></ul><h4>What problems does redux solve?</h4><ul><li>I think Redux is like a global state manager? So that you can have more control over some variables that you want to share without prop drilling.</li></ul><h4>What are libraries you have used?</h4><ul><li>Moch/Chai, React, Cypress, played around with chart.js</li></ul><h4>How are props different from state?</h4><ul><li>State is where our hard and fast data is stored. We need to have a source of truth, and that is state. Props are often representations of state — but can be passed from component to component without making state/data vulnerable.</li></ul><h4>Do you know the concept of SCRUM?</h4><ul><li>Scrum is <strong>a framework that helps teams work together</strong>. … Often thought of as an agile project management framework, scrum describes a set of meetings, tools, and roles that work in concert to help teams structure and manage their work.</li></ul><h4>What is JSX?</h4><ul><li>JavaScript XML</li></ul><h4>How is JSX different from HTML?</h4><ul><li>HTML: Hyper Text Markup Language — all the elements and so forth that are the bones of a webpage. A standard language for documents.</li><li>My code is either already in HTML or compiled so browsers can read it as HTML</li><li>JSX: Javascript XML. Syntatic Sugar! for React.createElelment( ). It is an extension of JS that allows devs to write HTML within Javascript.</li></ul><h4>Explain how a branch works</h4><ul><li>A branch separates from main — main representing the trunk of the codebase, where all approved changes eventually flow. A branch will include code from main — that can be altered, added too, detracted from, tested, styled, etc — and then pushed to back into main to grow the main.</li></ul><h4><strong>What can you tell me about Rest APIs?</strong></h4><ul><li>When a client request is made via a RESTful API, it transfers a representation of the state of the resource to the requester or endpoint. This information, or representation, is delivered in one of several formats via HTTP: JSON (Javascript Object Notation), HTML, XLT, Python, PHP, or plain text. JSON is the most generally popular file format to use because, despite its name, it’s language-agnostic, as well as readable by both humans and machines.</li><li>Something else to keep in mind: Headers and parameters are also important in the HTTP methods of a RESTful API HTTP request, as they contain important identifier information as to the request’s metadata, authorization, uniform resource identifier (URI), caching, cookies, and more. There are request headers and response headers, each with their own HTTP connection information and status codes.</li></ul><h4><strong>Do you know what a bearer token is in terms of JWT?</strong></h4><ul><li>JWT: Json Web token</li><li>Short answer</li></ul><p>JWTs are a convenient way to <em>encode</em> and <em>verify</em> <strong>claims</strong>.</p><p>A Bearer token is just string, potentially arbitrary, that is used for authorization.</p><ul><li>Context (story time)</li></ul><p>A few years ago, before the JWT revolution, a &lt;token&gt; was just a string with no intrinsic meaning, e.g. 2pWS6RQmdZpE0TQ93X. That token was then looked-up in a database, which held the <strong>claims</strong> for that token. The downside of this approach is that DB access (or a cache) is required everytime the token is used.</p><p>JWTs <em>encode</em> and <em>verify</em> (via signing) their own <strong>claims</strong>. This allows folks to issue short-lived JWTs that are stateless (read: self-contained, don’t depend on anybody else). They do not need to hit the DB. This reduces DB load and simplifies application architecture because only the service that issues the JWTs needs to worry about hitting the DB/persistence layer (the refresh_token you&#39;ve probably come across).</p><h4><strong>What is CORS?</strong></h4><ul><li>Cross Origin Resource Sharing — essentially a security feature to ensure approved browers receive approved infomation</li></ul><h4><strong>Whats the difference between ES5 and ES6?</strong></h4><ul><li>ECMA Script 5(2009) and 6(2015). Used to standardize JS.</li><li>ES6 releases let and const and arrow functions</li></ul><h4>How do you interact with APIs on the front end?</h4><ul><li>I use API endpoints to get data, post data, etc(Get, Put, Post, Patch, Delete)</li></ul><h4>Whats the difference between an HTTP request and response?</h4><ul><li>Request comes from the client. Response comes from the server.</li></ul><h4><strong>What does a 200 status code mean?</strong></h4><ul><li>All good here!</li></ul><h4>What does a 400 status code mean?</h4><ul><li>Something wrong happened, and it’s not the server’s fault</li></ul><h4>Whats the difference between let and const?</h4><ul><li>const cannot be re-assigned. It is Constant</li></ul><h4>Whats your experience with React Hooks? Why use them?</h4><ul><li>useEffect, useState</li><li>Easier, more modular, clearer way to assign state, mutate state, and deal with side effects related to state</li></ul><h4>What is HTTP and give a brief definition?</h4><ul><li>Hyper Text Transfer Protocol</li><li>Foundation of the internet’s data communication</li></ul><h4>Explain a git merge workflow vs a git rebase workflow</h4><ul><li>Oh god…. rebasing means you work through changes one by one?</li></ul><h4>What is TDD and give a brief definition?</h4><ul><li>Test Driven Development</li><li>Test First (most of the time) to ensure you’re actually building what you want to build</li></ul><h4>What does API stand for and how do you define it?</h4><ul><li>Application Program Interface</li><li>It’s remote data — data that is over THERE. That you can get if you ask properly</li></ul><h4>What does it mean to compile code?</h4><ul><li>the transformation from Source Code (human readable) into machine code (computer executable)</li></ul><h4>How would you describe the prototype in Javascript?</h4><ul><li>JavaScript is often described as a <strong>prototype-based language</strong> — to provide inheritance, objects can have a <strong>prototype object</strong>, which acts as a template object that it inherits methods and properties from.</li></ul><h4>What is a Mock vs. a Stub in testing? When would you use each?</h4><ul><li>Stub: a piece of mock data that allows you to control every aspect of a response object</li><li>Mock: ?</li><li>Intercept: Catch an outgoing network request before in reaches a server and then send the stub instead</li></ul><h4>Describe each of the four fundamental concepts of object-oriented programming.</h4><ul><li>Inheritance</li><li>Encapsulation</li><li>Polymorphism</li><li>Data Abstraction</li></ul><h4>What does it mean for a function to be deprecated?</h4><ul><li>“retired”</li><li>taking older code and marking it as no longer useful</li></ul><h4>What is the difference between synchronous vs. asynchronous?</h4><ul><li>Synchronous: in sequence, a statement has to wait for an earlier statement to be executed</li><li>Asynchronous: move to another task before the previous task finished</li></ul><h4>Explain meta tags in HTML</h4><ul><li>Meta tags always go inside head tag of the HTML page</li><li>Meta tags is always passed as name/value pairs</li><li>Meta tags are not displayed on the page but intended for the browser</li><li>Meta tags can contain information about character encoding, description, title of the document etc</li></ul><h4>Name some basic design elements</h4><ul><li>LINE — The linear marks made with a pen or brush or the edge created when two shapes meet.</li><li>SHAPE — A shape is a self contained defined area of geometric (squares and circles), or organic (free formed shapes or natural shapes). A positive shape automatically creates a negative shape.</li><li>DIRECTION — All lines have direction — Horizontal, Vertical or Oblique. Horizontal suggests calmness, stability and tranquillity. Vertical gives a feeling of balance, formality and alertness. Oblique suggests movement and action</li><li>SIZE — Size is simply the relationship of the area occupied by one shape to that of another.</li><li>TEXTURE — Texture is the surface quality of a shape — rough, smooth, soft hard glossy etc.</li><li>COLOUR — Colour is light reflected off objects. Color has three main characteristics: hue or its name (red, green, blue, etc.), value (how light or dark it is), and intensity (how bright or dull it is).</li></ul><h4>What is Node.js?</h4><p>Node.js is a web application framework built on Google Chrome’s JavaScript Engine (V8 Engine).</p><p>Node.js comes with runtime environment on which a Javascript based script can be interpreted and executed (It is analogus to JVM to JAVA byte code). This runtime allows to execute a JavaScript code on any machine outside a browser. Because of this runtime of Node.js, JavaScript is now can be executed on server as well.</p><h4>What is Scope in JavaScript?</h4><p>In JavaScript, each function gets its own <em>scope</em>. Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function’s scoped variables.</p><p>A variable name has to be unique within the same scope. A scope can be nested inside another scope. If one scope is nested inside another, code inside the innermost scope can access variables from either scope.</p><h4>What is npm?</h4><p>npm stands for Node Package Manager. npm provides following two main functionalities:</p><ul><li>Online repositories for node.js packages/modules which are searchable on <a href="http://search.nodejs.org/">search.nodejs.org</a></li><li>Command line utility to install packages, do version management and dependency management of Node.js packages</li></ul><h4>What is webpack?</h4><p>Webpack is a build tool that puts all of your assets, including Javascript, images, fonts, and CSS, in a dependency graph. Webpack lets you use require() in your source code to point to local files, like images, and decide how they&#39;re processed in your final Javascript bundle, like replacing the path with a URL pointing to a CDN.</p><h4>What is Binding in React? When should you bind?</h4><p>Before we had ES6 arrow functions at our disposal, we had to manually bind our functions in the constructor, like this:</p><p>This took place in the constructor for a few reasons: you wouldn’t have to remember to bind it every place you wanted to pass it in the render, and it would only be declared once, when the constructor method was called. (Conversely, render is called every time the component state updates; there’s no need to have a bunch of identical bound addIdeas floating around in memory!)</p><p>You can see that using the arrow function is much shorter syntactically. However, it’s good to know the REASON behind using it, especially since some legacy codebases will still be using manually bound class methods.</p><h4>Explain how this works in JavaScript.</h4><p>this is a little tricky in JavaScript. Its value is determined by what the function you are inside of is called. In the global state, this is set to the window object. The value of this also depends on whether or not you are in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode">strict mode</a>. Inside a top-level function, a strict mode this will be undefined, whereas a non-strict mode this will be the window object. It&#39;s also worth knowing that the value of this can be overwritten with the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind">bind</a> method.</p><h4>How can you manipulate an Object?</h4><p>Object.keys, object.values, object.entries, add to an object, delete from an object.</p><p>You can add with dot notation object.key3 = “password”</p><p>You can delete with the delete operator</p><pre>const Employee = {<br>  firstname: &#39;John&#39;,<br>  lastname: &#39;Doe&#39;<br>};</pre><pre>delete Employee.firstname;</pre><pre>console.log(Employee.firstname);<br>// expected output: undefined</pre><h4>How do you merge an object?</h4><ul><li>Use a spread operator ( ...)</li></ul><pre>let person = {     <br>  firstName: &#39;John&#39;,     <br>  lastName: &#39;Doe&#39;,     <br>  age: 25,     <br>  ssn: &#39;123-456-2356&#39; <br>};   </pre><pre>let job = {     <br>  jobTitle: &#39;JavaScript Developer&#39;,     <br>  location: &#39;USA&#39; <br>};  </pre><pre>let employee = {     <br>  ...person,     <br>  ...job <br>};</pre><ul><li>Use the Object.assign() method</li></ul><pre>Object.assign(target, sourceObj1, sourceObj2, ...);</pre><pre>// Example:<br>let employee = Object.assign(person, job);</pre><h4>What is a deep copy versus a shallow copy?</h4><p><strong>Shallow copy</strong></p><ul><li>Shallow copy is a bit-wise copy of an object. A new object is created that has an exact copy of the values in the original object. If any of the fields of the object are references to other objects, just the reference addresses are copied i.e., only the memory address is copied.</li></ul><p><strong>Deep copy</strong></p><ul><li>A deep copy copies all fields, and makes copies of dynamically allocated memory pointed to by the fields. A deep copy occurs when an object is copied along with the objects to which it refers.</li></ul><p>Describe how CSS works, the cascade, what rules take precedence?</p><ul><li>How do you manage state in a React App? Have you used Redux? (no) Follow up: without GSM, how do you manage state? Do you keep things more central and prop drill or spread things out between components, why?</li></ul><h4>Can you explain any common techniques or recent issues solved in regards to front-end security?</h4><h4>Explain what ARIA and screenreaders are, and how to make a website accessible.</h4><p>Accessible Rich Internet Applications <strong>(ARIA)</strong> is a set of attributes that define ways to make web content and web applications (especially those developed with JavaScript) more accessible to people with disabilities.</p><h4><strong>Explain the difference between cookies, session storage, and local storage?</strong></h4><h4>Why is it called a Ternary operator, what does the word “Ternary” indicate?</h4><p>The <strong>conditional (ternary) operator</strong> is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is <a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">truthy</a> followed by a colon (:), and finally the expression to execute if the condition is <a href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy">falsy</a>. This operator is frequently used as a shortcut for the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else">if</a> statement.</p><h3>What is HTTPS?</h3><p>Hypertext Transfer Protocol Secure is a version of HTTP (Hypertext Transfer Protocol) that is encrypted. This means that sensitive data like passwords are not able to be read while in transit. Any sensitive information should be sent over HTTPS. Companies like Google are even starting to push that all websites should be served over HTTPS as its become readily available and fast.</p><h3>What is XSS?</h3><p>Cross-Site Scripting attacks are when an attacker sneaks some malicious code into a web page viewed by others. Think of a social media site like Facebook. If you uploaded an image that looked like &lt;img src=&quot; javascript:alert(&#39;hello everybody&#39;)&quot;&gt;&lt;/img&gt;, you can imagine the surprise other users would have when they clicked on your image and saw a browser alert!</p><h3>What is a SQL injection?</h3><p>Another type of attack. If you have a search form, for example, and when a user types in a name like “Kelly” you take that string and do an SQL lookup for it. Let’s say your SQL looks like this:</p><p>SELECT * FROM Users WHERE UserId = yourVariable</p><p>An attacker could put something malicious in the search bar like Kelly OR 1=1, and now it will return a list of all users instead of just the requested one.</p><ul><li>Explain event delegation.</li><li>Explain how prototypal inheritance works.</li><li>What’s the difference between a variable that is: null, undefined or undeclared?</li><li>What is a closure, and how/why would you use one?</li><li>What language constructions do you use for iterating over object properties and array items?</li><li>Can you describe the main difference between the Array.forEach() loop and Array.map() methods and why you would pick one versus the other?</li><li>What’s a typical use case for anonymous functions?</li><li>What’s the difference between host objects and native objects?</li><li>Explain the difference between: function Person(){}, var person = Person(), and var person = new Person()?</li><li>Explain the differences on the usage of foo between function foo() {} and var foo = function() {}</li><li>Explain “hoisting”.</li><li>What’s the difference between an “attribute” and a “property”?</li><li>What are the pros and cons of extending built-in JavaScript objects?</li><li>What is an example of an immutable object in JavaScript?</li><li>What is the event loop?</li><li>What is the difference between call stack and task queue?</li><li>What are the differences between variables created using let, var or const?</li><li>What are the differences between ES6 class and ES5 function constructors?</li><li>What advantage is there for using the arrow syntax for a method in a constructor?</li><li>What is the definition of a higher-order function?</li><li>Can you give an example for destructuring an object or an array?</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e7e059ee2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React: Hook before you leap]]></title>
            <link>https://k-atwhite.medium.com/react-hook-before-you-leap-9c546e70716c?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c546e70716c</guid>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Mon, 04 Oct 2021 22:06:49 GMT</pubDate>
            <atom:updated>2021-10-27T21:37:54.998Z</atom:updated>
            <content:encoded><![CDATA[<p>I first learned React through class components and functional components, liberally salting and peppering my web app with “this.state”. After one project at Turing we moved on, thank goodness, to Hooks.</p><figure><img alt="crochet hook" src="https://cdn-images-1.medium.com/max/1024/1*w1eogBdIR_T_rWBa37G1yQ.jpeg" /></figure><h3>Table of Contents</h3><p><a href="#a1e8">Tell Me About Hooks</a><br><a href="#fbdf">State Hook</a><br><a href="#cbed">Effect Hook</a><br>- <a href="#b594">Component Lifecycle Refresher</a><br>- <a href="#826b">useEffect as componentDidMount</a><br>- <a href="#44b6">useEffect as componentDidUpdate</a><br>- <a href="#a1e6">useEffect as componentWillUnmount</a></p><h3>Tell me about Hooks</h3><ul><li>they are functions</li><li>They *must* live inside a functional component</li><li>They sneak you into React state and lifecycle features (more on this below)</li><li>Using hooks means you don’t need class components 👏👏👏</li><li>Don’t call a hook in a loop, condition, or nested function!</li><li>React has built in hooks. But you can also create your own custom hooks</li></ul><h3><strong>State Hook</strong></h3><ul><li>Adds state to a functional component</li></ul><p>setState is your bread and butter — it’s what hooks and react are all about: easy, modular ways to organize and manipulate your state.</p><p>The state hook has two very handy parts:</p><ol><li>the current state value</li><li>A function to update that state</li></ol><p>Here’s the basic template:</p><pre>const [state, setState] = useState(initialState);</pre><p>Here’s how you call it:</p><pre>setState(newState);</pre><p>You can store an object in your initial state to clean up your code a bit.</p><p>For example:</p><pre>const [results, setResults] = useState(<br>  {    <br>    name: &#39;&#39;,<br>    isLoggedIn: false <br>  }<br>)</pre><pre>// set state with an object like so:</pre><pre>setResults({<br>  name: &#39;Mark Corrigan&#39;,<br>  isLoggedIn: true<br>})</pre><p>That’s the long and short of it. useSate is often relatively straightforward!</p><h3>Effect Hook</h3><ul><li>Adds “side effect behavior” to a functional component.</li></ul><p>I didn’t really know what this meant until I wrote this article. I was sort of haphazardly adding in useEffect so that I could fetch from APIs and set state from there. But that mindless tactic meant i frequently ran into errors.</p><p>I think the first question to address is: What do you mean a “side-effect”?</p><p>Side effects are basically anything that affects something outside of the scope of the current function that’s being executed. Side Effect is also not a term specific to React — it’s more generally describing function behavior. Do you need some examples? I did:</p><ul><li>Making asynchronous API calls for data</li><li>Setting a subscription to an observable</li><li>Manually updating the DOM element</li><li>Updating global variables from inside a function</li></ul><p>So… my initial use of useEffect to make an API call wasn’t necessarily wrong, but I was missing key concepts.</p><h4>Quick Detour to the React Component Lifecycle</h4><p>Let’s add a layer of complexity before we continue — because you really can’t understand what is happening without <em>actually</em> understanding the React life cycle.</p><p>First things first, THERE ARE THREE STAGES.</p><p><strong>1️⃣ Mounting</strong>: The FIRST render of the component</p><p><strong>2️⃣ Updating</strong>: Changes made to the component</p><p><strong>3️⃣ Un-mounting</strong>: Stop showing the component</p><p>Without Hooks, you have probably used</p><p>1️⃣componentDidMount</p><p>2️⃣componentDidUpdate</p><p>3️⃣componentWillUnmount</p><p>useEffect can replace each of these lifecycle methods, depending on how you write the function.</p><h4>useEffect as componentDidMount</h4><p>Notice the empty array on line 4. The empty array means you <strong>only</strong> want this to run during the first render, i.e. during the “Mount”. This useEffect is essentially acting as componentDidMount. That empty array is actually a second argument telling useEffectto run only when the component mounts.</p><pre>1   useEffect(() =&gt; {<br>2    console.log(&quot;useEffect ran&quot;)<br>3    console.log(&quot;More specifically, the component has mounted&quot;)<br>4   }, [])</pre><h4>useEffect as componentDidUpdate</h4><p>The below code blocks are examples of useEffect that is going to run when there is a change to your component. Similar to componentDidUpdate.</p><p>BAD EXAMPLE: In the below example you’ll notice no dependency array. React assumes that argument is undefined and thus runs useEffect after <strong>every single </strong>update to anything. This is chaotic — you probably don’t want to do this.</p><pre>1   useEffect(() =&gt; {<br>2    console.log(&quot;useEffect ran&quot;)<br>3   })</pre><p>In the below example, with a dependency array, useEffect is only keeping a tab on the user variable and updating when that variable changes. You can add more than one variable to your dependency array.</p><pre>1   useEffect(() =&gt; {<br>2    console.log(&quot;useEffect ran and user &quot;)<br>3   }, [user])</pre><h4>useEffect as componentWillUnmount</h4><ul><li>AKA — the clean up function.</li></ul><p>Let’s think of an example where this would be useful. <a href="https://www.youtube.com/watch?v=DTlmk6QeOHY">This video</a> broke the problem down in the simple way I needed. I will be using his example:</p><ul><li>Say you have a button that when pressed will show the coordinates of your mouse on the screen. As you move your mouse along the screen, the display shows the coordinates change. Say you click the button again, and that coordinate display disappears from your DOM. BUT — you suddently get this error:</li></ul><p>Warning: Can&#39;t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.</p><p>What the hell is a subscription? What do you mean a memory leak? How do I fix this.</p><p>Basically — you unmounted the component, but you’re still asking me to update variables for that unmounted component! You need to clean up after yourself! Cue the useEffect clean up function. Here’s how.</p><p>Whatever you return in your useEffect IS your cleanup function. Below — right now your clean up function is just a console log.</p><pre>useEffect(() =&gt; {<br>  console.log(&quot;useEffect ran&quot;)</pre><pre>  return () =&gt; {<br>    console.log(&quot;clean up!&quot;)<br>  }<br>}, [])</pre><p>I found a lot of videos about subscriptions, and redux, and aborting — and honestly I don’t understand it right now. But, a simple way to clean up after yourself is to do the opposite of what you wanted in the first place! In this mouse coordinates example — you can pass a return function that removes an event listener from your logMousePosition.</p><p>Next, I intend to research the below hooks and get a little deeper into React.</p><p><a href="https://reactjs.org/docs/hooks-reference.html"><strong>useReducer</strong></a><strong>: </strong>is usually preferable to useState when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one. useReducer also lets you optimize performance for components that trigger deep updates because you can pass dispatch down instead of callbacks.</p><p><a href="https://reactjs.org/docs/hooks-reference.html"><strong>useCallback</strong></a><strong>:</strong> will return a memoized version of the callback that only changes if one of the dependencies has changed. This is useful when passing callbacks to optimized child components that rely on reference equality to prevent unnecessary renders (e.g. shouldComponentUpdate).</p><p><a href="https://reactjs.org/docs/hooks-reference.html"><strong>useMemo</strong></a>: will only recompute the memoized value when one of the dependencies has changed. This optimization helps to avoid expensive calculations on every render.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c546e70716c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How come everything is free?]]></title>
            <link>https://k-atwhite.medium.com/how-come-everything-is-free-eab39150cf3f?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eab39150cf3f</guid>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Wed, 14 Jul 2021 01:30:10 GMT</pubDate>
            <atom:updated>2021-07-14T02:33:30.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZWfnf6hViAQgygl1qurAQ.jpeg" /></figure><p><em>I typed “free” into unsplash and this hilarious picture came up. That’s me typing npm…</em></p><p><em>tldr; freemium</em></p><p>I don’t mean - <em>how come facebook and game apps are free? </em>We know that’s data mining and micro-transactions, don’t we.</p><p>I mean all the useful software stuff. Just now, while downloading “Router” into my app built off “create react app” — and checking my node_modules folder, it suddenly occurred to me. This is free…</p><p>In my other careers, few tools were free. You have to pay for Photoshop and InDesign, you have to pay for Autodesk. You have to pay for ArcMap. You have to pay for Microsoft Word and Xcel.</p><p>Everything at Turing is free ! (except for Turing it$elf).</p><p>How come I can use GitHub, WebPack, Router, testing framekworks, Create React App, a million npm modules for free?</p><p>I researched, and some people on quora put in their two cents. Suggestions like “giving back to society” seem tenuous to me, so I did a bit of research on GitHub to begin understanding — free software.</p><p>To start, I tried a couple searches that yielded nothing:</p><p><em>Why is GitHub free? How is GitHub free?</em></p><p>Then I realized I was asking the question the wrong way. What I really wanted to ask was :</p><p><em>How does GitHub make money?</em></p><p>Here’s a quick GitHub timeline</p><p>2008 — founded in SanFrancisco by Tom Preston-Werner, Chris Wanstrath, and P. J. Hyett</p><p>First 6 months: GH hosted 10,000 open source projects</p><p>2012 — GH receives $100 million investment from Andreessen Horowitz (I don’t know Venture Capital companies —I figured it was a Dutch/Jewish fella. It’s actually a private VC firm founded by Marc Andreessen and Ben Horowitz)</p><p>2015 — Rival product, Google Code, shuts down</p><p>2017 — Rival product, Microsoft CodePlex, shuts down</p><p>2017 — GH receives series B funding, $250 from Sequoia Capital</p><p>Meanwhile — GH is pushing it’s business to included enterprise customers</p><p>2018 —GH generates annual revenue of $300 million. Microsoft acquires GH for $7.5 billion in stock</p><p>2019 — GH announces free users receive unlimited private repositories</p><p>2020 — GH announces all teams will also receive unlimited private repositories</p><ul><li>* Fun fact — China has it’s own version called Gitee. Read about it here(<a href="https://techcrunch.com/2020/08/21/china-is-building-its-github-alternative-gitee/">https://techcrunch.com/2020/08/21/china-is-building-its-github-alternative-gitee/</a>)</li></ul><p>Clearly GH is valuable. But HOW does it make money. <strong>Freemium</strong>, baby. This is common business strategy, you’ve seen it. You, user with lowly intentions, are entitled to partial use of the product in return for your e-mail address. Paying users receive more/better services.</p><p>Basically, if you start scaling your projects, you will need to step into one of the premium plans.</p><ul><li>Team — 4$/month</li><li>Enterprise — $21/month</li><li>GitHub One — pricing available upon request</li></ul><p>There’s also the GitHub marketplace, where you can pay for apps that link to your GH.</p><p>But there’s more than money at stake here. The Harvard Business Review writes about the difference between financial and strategic value — and argues that Microsoft didn’t buy GitHub based on its revenue, but rather on GH’s ability to be a funnel into Microsoft’s developer environment.</p><p>So, that’s how it’s free. It’s so popular and useful, that it put Google and Microsoft’s version out of business, and a lot of people pay for it. But users aren’t necessarily paying enough for that to be the REASON Microsoft bought it.</p><h3>Coming Soon…</h3><p>I want to write more about Open Source next, TRULY free products and projects. This is for another time! Here’s a teaser:</p><h4>Open Source</h4><p>I use SO MANY open source tools. It’s dizzying. Wikipedia is one of the only organizations I’ve ever donated to. Even though I (and clearly most people) love open source technology, I cannot understand what keeps it afloat.Passion projects, sure — putting time and effort into something you either believe is societally important, or something you genuinely enjoy. But what I don’t understand is how large-scale passion projects survive over time. The lack of material compensation defies my understanding of human motivation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eab39150cf3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WEBPACK: can you believe how much I can get away with not knowing???]]></title>
            <link>https://k-atwhite.medium.com/webpack-can-you-believe-how-much-i-can-get-away-with-not-knowing-e9d415862586?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9d415862586</guid>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Thu, 01 Jul 2021 19:27:06 GMT</pubDate>
            <atom:updated>2021-07-01T19:29:10.820Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="webpack infographic of bundling" src="https://cdn-images-1.medium.com/max/1024/0*1w8bT2oGObJyYD_O.png" /></figure><p>I think I’ve used a webpack starter kit about four times now. Before each project I said to myself “<em>I’m gonna try to actually understand what webpack is doing</em>.”</p><p>But then I started my project, began figuratively drowning, saw the massive block of text in my terminal with the word “webpack” dotted throughout what is ostensibly English but might as well be another language and I said to myself, <em>“next time, i’ll read about webpack next time”</em></p><p>Because Turing’s Mod 3 focuses heavily on react — and Create React App relies heavily on webpack, now seems like a good time to start my research.</p><p>Warning! This is a <em>lite</em> explanation that I am using to begin understanding. For a more comprehensive explanation, I suggest you read through <a href="https://www.freecodecamp.org/news/lets-learn-how-module-bundlers-work-and-then-write-one-ourselves-b2e3fe6c88ae/">this article</a> from freecodeacademy, and watch <a href="https://www.youtube.com/watch?v=5IG4UmULyoA">this video</a> from fireship.</p><h3>Intro</h3><p><strong><em>webpack is an open-source JavaScript module bundler.</em></strong></p><p><strong>Open-Source</strong>: This just means that the software’s code is free and can be modified. I honestly also think it’s important to note that people REALLY get off on open source code. I think there are three reasons for this.</p><ol><li>People involved in the early days of the internet have a deep sense of nostalgia and respect for the wild west days.</li><li>The internet today is a cesspool of data sucking, ad blaring, fake news swamp monsters that will do anything for your money and your eyeball hang time.</li><li>Everyone loves Robin Hood</li></ol><p><strong>Module Bundler: </strong>This is a tool — it turns JavaScript and dependencies into a single file. It’s usually for use in a browser.</p><p>Ok. So Those are the most basic points to understand. Anyone can use it/change it. And it takes your files and bundles it up into one thing.</p><h3>Let’s talk about how</h3><p><em>(I am paraphrasing heavily from </em><a href="https://www.freecodecamp.org/news/lets-learn-how-module-bundlers-work-and-then-write-one-ourselves-b2e3fe6c88ae/"><em>freecodeacademy</em></a><em>)</em></p><p>Ok! So you start off with an “entry file” — this tells the bundler where to begin. It could look like this:</p><pre>module.exports = {<br>  entry: &#39;./path/to/my/entry/file.js&#39;,<br>};</pre><p>Then, there are two main stages:</p><ol><li>Dependency Resolution</li><li>Packing</li></ol><h3>Dependency Resolution</h3><p>Goal: Graph all dependencies (all the pieces of code needed for functionality), then convert dependency graph into a single file</p><p>To begin we need:</p><ul><li>The name and an identifier of the file</li><li>Where the file came from (in the file system)</li><li>The code in the file</li><li>What dependencies that file needs</li></ul><p>The graph structure made up of all dependencies is best represented as an object (in JS)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*YMqTKLT7K-k9yNCz.png" /></figure><p>The getModules function is a heavy lifter, but in essence it starts at the entry file and then searches out and “resolves” dependencies.</p><p>Resolve seems to just mean finding out WHERE the required file/dependency is. Node and npm have an alogorithm and a module that do all that for you. Honestly, I still don’t understand how. But suffice to say, we just have to pass in the dependency and base URL and it will take care of it for us. Thank you. At the end, we have an array named modules that contains each module object in the project. Now, we are ready to bundle.</p><h3>Packing</h3><p>Ok… I’ve invested about 40 minutes into youtube videos so far into trying to understand this concept. For the sake of this <em>lite</em> blog post, I’m going to try to provide a pared down description — but I know it is totally insufficient.</p><p>So — you now have all your dependences, js files, react components — they have been graphed recursively so that when the package is given to the browser each portion of your code is unbundled in the correct order. You’ve got your bundle.js.</p><p>I am certainly unsatisfied with my present understanding and the clarity of this article. But, let’s hold on to this for now. And I’ll add information as the concepts become clearer!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9d415862586" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[bracket notation: why is my brain broken?]]></title>
            <link>https://k-atwhite.medium.com/bracket-notation-who-is-she-and-why-is-my-brain-broken-56cdfc3094bd?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/56cdfc3094bd</guid>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 21:37:34 GMT</pubDate>
            <atom:updated>2021-06-12T14:34:53.630Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="a super excited weimaraner looking at its owner’s hand about to throw a green ball" src="https://cdn-images-1.medium.com/max/1024/1*tUCm3oiLGu0AJhURpHh-DA.jpeg" /></figure><p>I’m afraid these posts are already turning into me just complaining about hard concepts.</p><p>And they are sorta… But, if you’re a fellow kvetcher, welcome! You’ll never hear “good vibes only” come out of my mouth. Except just then, to say that I wont say them.</p><p>I digress. Learning all day every day is exhausting. It is a privilege. But for me, it’s also utterly draining. I found that my mind appreciates long stretches of time where I either don’t think about anything (i.e. watch British panel shows). Or I only think about the things I want to think about — … say, when we leave the house without our dog (Matilda), does she think we are going to the dog park without her?</p><p>I digressed again. <strong>Bracket notation!</strong> I’m writing this post 4 days before Mod 2’s final assessment . I’m writing it because I suspect the reason I’m having such a difficult time with the more complicated iteration problems is because my grasp of bracket notation is poor. Hopefully I can fix that today.</p><h4>The Basics</h4><p>First, let’s talk about what bracket notation <em>isn’t.</em></p><p>It isn’t <strong>dot notation.</strong></p><p>When do you use dot notation? <strong>When you know the exact property you want to access. </strong>JavaScript interprets the expression in the exact way you write it and looks for that exact key.</p><p>Then when do we use <strong>bracket notation</strong>?</p><p><strong>When we don’t know the property key, or if they key changes (iterators, wink wink)</strong>. By adding those square brackets, we are forcing JavaScript to do one more step and evaluate everything in between the brackets.</p><p>[ evaluationInProcess ]</p><p>Js finds the key that matches what your brackets evaluated to, and returns the value.</p><p>This is obviously simplified. But the main take away is that bracket notation is your friend when the property that you are looking for is unknown or will change.</p><p>For my purposes, I want to go through a few iterator problems and annotate each line explicitly. And I have NO idea who is ever going to read this — maybe a Mod2 Turing student? Maybe my future boss (hey boss, looking good today!).</p><p>Here is the data we are playing with. What do you notice?</p><pre>const orders = [<br>  {<br>    type: &#39;cake&#39;,<br>    name: &#39;Strawberries &amp; Cream Cake&#39;,<br>    price: 40,<br>    size: 6,<br>    customer: &#39;Olivia&#39;,<br>    specialConsiderations: &#39;gluten free*pick up on Thursday afternoon*birthday cake&#39;<br>  },<br>  {<br>    type: &#39;tart&#39;,<br>    name: &#39;Chocolate Raspberry Tart&#39;,<br>    price: 25,<br>    size: 8,<br>    customer: &#39;Cody&#39;,<br>    specialConsiderations: &#39;pick up on Friday*no allergies&#39;<br>  },<br>  {<br>    type: &#39;cake&#39;,<br>    name: &#39;Chocolate Cake&#39;,<br>    price: 40,<br>    size: 6,<br>    customer: &#39;Ramiro&#39;,<br>    specialConsiderations: &#39;olive oil allergy*add cream cheese icing*simple decoration&#39;<br>  },<br>  {<br>    type: &#39;cake&#39;,<br>    name: &#39;Funfetti Cake&#39;,<br>    price: 0,<br>    size: 6,<br>    customer: &#39;Leta&#39;,<br>    specialConsiderations: &#39;none&#39;<br>  }<br>];</pre><p>It’s an array (thank goodness)!</p><p>Also, omg I have remember to add my own ending brackets and parentheses in Medium’s code block. Yeesh.</p><p>Below are the problems, solutions, and the way I went about solving the problem. There are many ways beside my own.</p><h3>Level One</h3><p>Write a function that will total up the profit of all orders.</p><pre>A SOLUTION:</pre><pre>const profit = () =&gt; {<br>  return orders.reduce((acc, order) =&gt; {<br>     acc += order.price<br>    return acc<br>  }, 0)<br>}</pre><pre>THE RETURN:</pre><pre>105</pre><pre>THE BREAKDOWN:</pre><pre>// an arrow function called profit with no parameter<br>const profit = () =&gt; {</pre><pre>// iterating through orders array - with my accumulator and each order<br>  return orders.reduce((acc, order) =&gt; {</pre><pre>// accumulator is adding each order&#39;s price to the total each loop<br>    acc += order.price</pre><pre>// always return your accumulator<br>    return acc</pre><pre>// my initial value is 0 - adding to this each loop<br> }, 0)</pre><pre>}</pre><h3>Level Two</h3><p>Refactor your function to organize your orders by type (ex: ‘cake’ and ‘tart’) — keeping track of the names and total profit for that type.</p><pre>A SOLUTION: </pre><pre>const profit = () =&gt; {<br>  return orders.reduce((acc, order) =&gt; {<br>    if (!acc[order.type]) {<br>      acc[order.type] = {names: [], totalProfit: 0}<br>    }<br>    acc[order.type].names.push(order.name)<br>    acc[order.type].totalProfit += order.price<br>  return acc<br>  }, {})<br>}<br></pre><pre>THE RETURN:<br>{<br>  cake: {<br>    names: [ &#39;Strawberries &amp; Cream Cake&#39;, &#39;Chocolate Cake&#39;, &#39;Funfetti Cake&#39; ],<br>    totalProfit: 80<br>  },<br>  tart: { names: [ &#39;Chocolate Raspberry Tart&#39; ], totalProfit: 25 }<br>}<br></pre><pre>THE BREAKDOWN: </pre><pre>const separateTypes = () =&gt; {</pre><pre>// iterate through orders array<br>  return orders.reduce((acc, order) =&gt; {</pre><pre>// IF the accumulator object doesn&#39;t already have &quot;cake&quot; or &quot;tart&quot; as a property...<br>    if(!acc[order.type]) {</pre><pre>// THEN name the key whatever order.type evaluates to and assign it to an empty object<br>      acc[order.type] = {}</pre><pre>// THEN assign give that object another property &quot;names&quot; and assign  the value to an empty array<br>      acc[order.type].names = []</pre><pre>// THEN give that object another property &quot;totalProfit&quot; and assign the value to zero      <br>      acc[order.type].totalProfit = 0</pre><pre>    }</pre><pre>// Your IF statement is over - NOW, push the name of each order into the names array<br>    acc[order.type].names.push(order.name)</pre><pre>// And add each oder&#39;s price to the total profit   <br>   acc[order.type].totalProfit += order.price</pre><pre>// You&#39;re done baby<br>  return acc</pre><pre>  }, {})</pre><pre>}</pre><p>That was an example using just one dataset — I find the brackets get a bit more confusing when you are working with two data sets ands need to start using Object.keys or Object.values.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56cdfc3094bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[projects and group dynamics]]></title>
            <link>https://k-atwhite.medium.com/projects-and-group-dynamics-7b4245626054?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b4245626054</guid>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Sat, 05 Jun 2021 23:51:30 GMT</pubDate>
            <atom:updated>2021-06-10T20:46:18.397Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGCcxAmgPcCJFDC4HDeW_w.jpeg" /></figure><p><em>First off — I love choosing the pic at the top of each of these posts. I suspect they are trite and forgettable, but I do put a lot of thought into them</em></p><p>I find group dynamics difficult.</p><p>Sometimes I forget that fact because I’m so often surrounded by people I already love and know well. Their personalities, needs, and idiosyncrasies don’t usually surprise me.</p><p>At this coding bootcamp, a surprising mental load has not been the — stressful, confusing, complicated projects with a deadline — but the group dynamics.</p><p>Here’s why I think they are difficult:</p><h4>Lots of voices</h4><p>I keep thinking about that idiom “Go alone and you go fast. Go together and you go far”. That’s got to be true right? I mean… it’s an idiom! <br>But… There’s something about individual coding problems — where there are many voices talking at once. And each individual has a different understanding of:</p><ol><li>what the problem even is</li><li>the best way to reach an answer</li><li>the factors that are potentially causing the issue</li></ol><p>It’s dizzying. Whose idea do you decide to go with? The loudest? The one who is correct most often? The most repetitive? The most quiet? The one who projects the most confidence? The one who fixed the <em>last</em> problem? I have no idea. Perhaps that is the mark of a good leader, is knowing at what time to listen to which voice.</p><h4>Levels and Leadership</h4><p>Wow- levels. By this I mean ability and aptitude. These projects at Turing are a DOOOZY because everyone is operating on SUCH different levels depending on the situation. Often, a hierarchy forms naturally. Someone who understands what to do more than everyone else — whether they like it or not, they have to lead. In my experience, unwilling leaders (people who are a level above and aren’t all crazy egotistical about it) are the best. They are gentle and kind and often quite good at explaining things.</p><p>There are individuals who are desperate to lead and I’ve found they often know a bit less than they think they do… not sure what that’s about. (I also think that I can fall into this category and I’m actively working on it.)</p><h4>Feelings.</h4><p>I almost started writing “communication”. But honestly that word has been used so incessantly over the last couple months that I barely even know what it means anymore. So… what do I really want to say with the word “communication”. I want to convey something about words, intent, meaning, needs, reactions, conflict, compromise… that’s rooted in people’s feelings, right? Ok — so FEELINGS.</p><p>When I start to get to know someone better, I’m often surprised to find out how people felt during previous shared experiences. Their reaction, their desires, the compromises they make in their own mind — are often NOT what they displayed. I guess what I’m trying to say is that people are quite mysterious. And I love that, but I also want to be a battering ram and break through that mystery and really FIGURE OUT what someone is about! That’s communication right? And does that usually happen at work? During school projects? Under time constraints? No. It happens slowly over time or during a shared traumatic event. (I do think Turing is a shared traumatic event).</p><p>Anyway — all that to say. The word “communication” seems to get boiled down into:</p><p><em>“Are you free from” 4pm-7pm?”</em></p><p><em>“No. I am free from 5pm-7pm”</em></p><p><em>“ok”</em></p><p><em>“Great. see you on zoom”</em></p><p><em>— chat 4ever about broken javascript functions —</em></p><p>I don’t see a way around this issue — ESPECIALLY in remote learning. It’s hard to get close to people and to understand what the heck they NEED from you when you never get to sit on a patio with them and shoot the shit. And, besides all that, people being mysterious is just part of “living in a society”.</p><p>Did I make a point with this post? No, I’m only trying to say that feelings, and mystery, and difficulty are a big part of why group dynamics are difficult. And for me, putting words down help me try be a better teammate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b4245626054" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Array Prototype Methods: A love story]]></title>
            <link>https://k-atwhite.medium.com/array-prototype-methods-iterators-fea30e2537f7?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fea30e2537f7</guid>
            <category><![CDATA[turing-school]]></category>
            <category><![CDATA[array-prototype]]></category>
            <category><![CDATA[iterators]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 16:11:09 GMT</pubDate>
            <atom:updated>2021-08-18T17:17:56.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaraTfPb-fMnH9DbtV5KVw.jpeg" /></figure><p>Before I can understand anything complicated— I need a clear, concise foundation. I don’t think I’m alone in this need.</p><p>One of the problems I’ve encountered as a student is that sometimes the person teaching me has totally forgotten what it felt like <em>not to know</em>. Some of my best teachers remember the beginner’s mind and the faulty paths it can go down, They will quickly pick me up and set me on the right path!</p><p>SO! This is an effort to break down iterators as clearly as possible! Really, just for me, but maybe it will help someone else too.</p><ol><li>Arrays are objects.</li></ol><p>You know why? Because the index is the property, and the element in the index is the value.</p><p>2. Objects can have methods.</p><p>JavaScript has methods that are built in by the big brains who write javascript itself. These methods are floating in the ether and you can decide to just pop them into your code and use them.</p><p>In Mod 1 at Turing, we first learned prototype examples like:</p><p>.push( )</p><p>.shift( )</p><p>.pop( ).</p><p>We also learned about for loops.</p><p>In Mod 2, we are focusing heavily on Array Prototype Iterators. These are beefy loops with greater power and functionality.</p><h4>forEach()</h4><p>This little number is not <em>very</em> different from a for loop.</p><p>the forEach is the iterator you reach for when you don’t need a returned value or a returned array. You use it when you just need to DO something to your array. It’s good for “side effects” in your code.</p><p>array.forEach(element =&gt; put your logic here!)</p><h4>map( )</h4><p>For me, the most important thing to remember about map() — is that map</p><p><em>always returns an array with the same number of items.</em></p><p>Map essentially applies a function to every item — and spits out a new array that was computed from the original.</p><p>const increasedPrices = prices.map(price =&gt; price + 2)</p><h4>find( )</h4><p>Find returns one element based on a test condition.</p><p>So — when you want <strong>a</strong> <strong>thing</strong> in the array to come out of that array — reach for find! Remember though, that it returns the FIRST value that meets that condition.</p><p>array.find(element =&gt; element &lt;10)</p><h4>filter( )</h4><p>If you want another array returned to you with JUST the stuff that yo want — reach for filter( ). It filters OUT the undesirables. It removes the items that don’t pass your condition.</p><p>const words = [&quot;spray&quot;, &quot;elite&quot;, &quot;destruction&quot;]</p><p>result = words.filter(word =&gt; word.length &gt; 6)</p><pre>// result = “destruction”</pre><p>As the iterator goes through each index in the array — if evaluates the parentheses, if what is between the parentheses evaluates to TRUE. that element is returned. But if you want it — you’ll need to push it assign it somewhere.</p><h4>reduce( )</h4><p>I love reduce. You should decide that you love reduce too. It’s great.</p><p>Reduce is that boi.</p><p>Reduce is flexible.</p><p>Reduce is powerful.</p><p>Reduce is mysterious at first.</p><p>Then reduce is your best pal.</p><p>Here is what I needed to understand reduce:</p><p>Basic Syntax:</p><p>array.reduce( (accumulator, currentArrayItem) =&gt; {</p><p>return accumulator</p><p>} , initialValue );</p><p>I personally needed each of these words to be broken up before I understood.</p><p>accumulator : This is the THING YOU WANT. It can be a sum of all numbers. It could be a brand new object. It is the basket you are putting the stuff you want in. I can be altered or added to with each iteration.</p><p>currentArrayItem : This is the current item in the array you are looking at in that particular iteration. I found it helpful to just name this the singular version of your plural array. Kitties become kitty. Cars become car. etc.</p><p>return accumulator : You need to return your accumulator or else the function does not work. Just write out the bones of your reduce iterator and always write this right away.</p><p>initial value : This is where the accumulator starts. It defaults to 0, but it’s good practice to define this value right away. If you are dealing with with numbers, start with a number. If your final desired output is an array, put brackets []. If you want an object, put curly braces {}.</p><h4>sort( )</h4><p>This little number is SO HELPFUL. But boy do I find the syntax confusing.<br>Let’s break this down.</p><p>This method sorts your array elements and returns the sorted array. By default — it will sort in ascending order. Your normal ABC.. etc. But for numbers it wont act the way you think.</p><p>For example if you have: [1, 30, 4, 21, 100000]</p><p>it will sort to : [1, 100000, 21, 30, 4]</p><p>You see what I mean? It will not go in terms of size, but everything that starts with 1 comes first, then 2.</p><p>That’s great when you have a simple array. But what if you need to sort the array by a property within each element? That’s when you need to pass some arguments.</p><p>You can “supply a compare function” — which is just asking to compare two elements against each other and then moving them. I found the below example from jsFun to be the most helpful:</p><pre>const kitties = [<br>  {<br>    name: &#39;Felicia&#39;,<br>    age: 2,<br>    color: &#39;grey&#39;<br>  },<br>  {<br>    name: &#39;Tiger&#39;,<br>    age: 5,<br>    color: &#39;orange&#39;<br>  },<br>  {<br>    name: &#39;Snickers&#39;,<br>    age: 8,<br>    color: &#39;orange&#39;<br>  },<br>  {<br>    name: &#39;Max&#39;,<br>    age: 1,<br>    color: &#39;tuxedo&#39;<br>  }<br>];</pre><pre>const result = kitties.sort((a, b) =&gt; b.age - a.age)<br>return result;</pre><pre>// { name: &quot;Snickers&quot;, age: 8, color: &quot;orange&quot; },<br> { name: &quot;Tiger&quot;, age: 5, color: &quot;orange&quot; },<br> { name: &quot;Felicia&quot;, age: 2, color: &quot;grey&quot; },<br> { name: &quot;Max&quot;, age: 1, color: &quot;tuxedo&quot; }]</pre><p>You see that the parameters (a, b) just represent two of the elements. You could put anything there to make it work.</p><p>But what it is doing in each pass is asking does the value of b.age -a.age equal?</p><p>In the first iteration is 5–2 &gt; 0? Yes? Then put b before a. Or Tiger before Felicia. Etc.</p><ul><li>If compareFunction(a, b) returns a value &gt; than 0, sort b before a.</li><li>If compareFunction(a, b) returns a value ≤ 0, leave a and b in the same order</li></ul><p>Welp, there you have it. Basic iterators!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fea30e2537f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I’m making myself like TDD]]></title>
            <link>https://k-atwhite.medium.com/im-making-myself-like-tdd-49d63ede8edc?source=rss-cc7ec433d02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/49d63ede8edc</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[turing]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bootcamp]]></category>
            <dc:creator><![CDATA[k white - writing about learning]]></dc:creator>
            <pubDate>Wed, 02 Jun 2021 17:35:10 GMT</pubDate>
            <atom:updated>2021-06-04T17:20:49.085Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gcZxlDfIi9nNHaWWI4gB-w.jpeg" /></figure><p>Right now, if I’m honest, I don’t like testing. It feels like a waste of time. And i feel like I’m writing the same code twice. But — people keep telling me that TDD is important for your personal growth, to learn how to write better code, and as a developer working on a team.</p><p>I’m willing to admit that I don’t like testing only because I don’t know how to do it. And what I personally need when I’m starting something new is a checklist. Oh boy do I love a good checklist. It makes me feel capable, ready, and in charge!</p><p>So, let’s make one for testing:</p><p>But first?</p><h3>Some Vocabulary</h3><p><strong>CHAI</strong>: Chai is an assertion library that is often used alongside Mocha. It provides functions and methods that help you compare the output of a certain test with its expected value.</p><p>Ok… what exactly is a <strong>LIBRARY</strong>? It’s a collection of packages that offer functionality. Oh my god, I feel like I’m 5. But what does functionality <em>mean</em>???</p><p><strong>FUNCTIONALITY</strong>: I’m aware this feels like overkill, but I personally want a clear definition. For now, I’m going to go with “ what your software does”. I think I find this kind of heady, because it’s where the abstract meets the tangible.</p><p><strong>MOCHA</strong> : A JavaScript test framework for Node.js programs.It features browser support, asynchronous testing, test coverage reports, and use of any assertion library. We start using Chai in Turing.</p><p>Ok.. that’s nice, but what is a test framework?</p><p><strong>FRAMEWORK</strong>: It’s an abstraction (it all is, man). It’s software with a generic sort of functionality that you the coder can change. It is a standard way to build applications and is a reusable and universal. Frameworks can include support programs, compilers, code libraries, toolsets, and <a href="https://en.wikipedia.org/wiki/Application_programming_interface">application programming interfaces (APIs)</a>. (ty wikipedia)</p><p><strong>DECLARATION:</strong> These provide the context of a specific test. Including the describe block and the it.(&#39;should be....&#39;)</p><p><strong>SET UP</strong>: creates conditions required to execute the action on SUT (system under test)</p><p>var unicorn = new Unicorn(&#39;Susan&#39;)</p><p><strong>EXECUTIONS</strong>: This part runs stuff to execute behavior . It does the thing.</p><p>unicorn.eat() (pretend that i made a method called eat)</p><p><strong>ASSERTION</strong>: The expected result after that action taken above</p><p>expect(unicorn.calories).to.equal(300)</p><h3>OUR CHECKLIST</h3><p>Now we have some a shared language — let’s make that checklist and start off simply.</p><h4>TEST FOR:</h4><ol><li>EVERY PROPERTY</li><li>IF THE PROPERTY CAN BE CHANGED — TEST FOR THE CHANGED STATE</li><li>EVERY METHOD</li><li>EVERY POSSIBLE OUTCOME FOR THE METHOD</li></ol><p>That’s the bare minimum. And in Turing, if I had ALL of those tests, I was usually in decent shape. But what about this happy and sad path testing?</p><h4>Happy Path</h4><p>This represents what we HOPE users will do. The “correct” way to use the app we just made. Testing choices you can make here include.</p><p>5. TYPING ONE WORD INTO SEARCH BAR</p><p>6. CHOOSING ONE BUTTON OPTION</p><p>7. ALL FORMS ARE CORRECTLY FILLED</p><h4>Sad Path</h4><p>This represents all the ways a user might interact with your app in a way you, the developer, did not anticipate.</p><p>This is harder to make a checklist for because it’s a known unknown. I read that some people try to understand users by writing detailed <em>personas</em>. You can imagine a target user and put yourself in their shoes. What happens if a person doesn’t know to fill out a form, choose their correct location, close a module? You have to use your imagination for this one!</p><p>8. USE OF INCORRECT DATA TYPE IN FORM</p><p>9. INCOMPLETE FORM</p><p>10. USE OF LOWER CASE / CAPITALIZATION</p><p>12. USE OF INCORRECT SPELLING</p><p>13. USE OF SPACES</p><p>You can see how this can go on and on. Part of the reason this is hard is because you have to use your imagination and because we’re new to this!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49d63ede8edc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>