1. If a user attempts to create a resource that already exists — for example, an email address that’s already registered — what HTTP status code would you return?
  • 409 is the most appropriate response code here. Even though you are most likely returning 201 on success, you’re still POSTing to a resource which is described as a collection, and POSTing a duplicate email is definitely a conflict with “the current state of the resource” as a collection. You should return a response body with a description of the problem, and hyperlinks to help resolve the problem, if possible.
  1. Consider a responsive site design that requires a full-width image in all responsive states. What would be the correct way to code this to ensure the page loads the smallest image required to fill the space?
  • You can use CSS media queries to set different screen sizes and as the screen changes, have either a size change of the image to fit or you can have different images that are different sizes and link them to each media query.
  1. When should you npm and when should you yarn?
  • NPM offers shrinkwrap CLI command. Yarn is faster and offers locked down versions of installed packages. Yarn is still newer and so older Node.js versions do not support it.
  1. How can you make sure your dependencies are safe?
  • To make sure your dependencies are safe, make sure to do all the research possible before downloading anything. Check the website out and see the versions and how frequently the dependencies get updated. Also, check other’s reviews and what others had to say about it.
  • When writing Node.js applications, ending up with hundreds or even thousands of dependencies can easily happen.
    For example, if you depend on Express, you depend on 27 other modules directly, and of course on those dependencies’ as well, so manually checking all of them is not an option!
  • The only option is to automate the update / security audit of your dependencies. For that there are free and paid options:
  • 1. npm outdated
    2. Trace by RisingStack
    3. NSP
    4. GreenKeeper
    5. Snyk
  1. What are the differences between CHAR and VARCHAR data types (MySQL)?
  • CHAR is a storage amount of the exact amount that you assign it, a fixed length. With VARCHAR, it only uses the amount of space that it needs based on what gets inputted.
  • CHAR is fixed length while VARCHAR is variable length. That means, a CHAR(x) string has exactly x characters in length, including spaces. A VARCHAR(x) string can have up to x characters and it cuts off trailing spaces, thus might be shorter than the declared length.
  1. How else can the JavaScript code below be written using Node.js to produce the same output?
  • We can use setImmediately to give the same output as setTimeout. We can also use setInterval.

console.log(“first”);

setTimeout(function() { console.log(“second”);

}, 0); console.log(“third”);

// Output: // first // third // second