Coder Social home page Coder Social logo

ad-tech-project's Introduction

Mic Ad Tech Programming Exercise

Hiya! Congratulations on getting to this point. The following exercise is meant to give us a basic understanding of your skills without the stress of white boarding or live coding challenges. It shouldn't take more than a few hours. We understand you have a life outside of interviewing!

Our goal here is to learn more about the thought process behind your work. You should write this code like you are part of our team. We are interested in the decisions you made, why you made them, and how you would explain these choices and the architecture so your team can understand it. Be prepared to speak about these topics!

THE EXERCISE: Mid Article Ad Injection Using JavaScript

The team has been tasked with increasing the average revenue per user. We've decided to place ads in the article body, but we want to do so in a way that does not hurt the user's ability to consume the story. The implementation should:

  1. Place an ad every 400 words, so that the ad appears after the paragraph containing the 400th word.
  2. Don't place an ad directly before or after an <img />, move it up a paragraph if possible.
  3. Don't place an ad at the end of an article, i.e. after the last paragraph.
  4. If the article has any words contained in the blacklist (case insensitive), don't append any ads.

You'll want to fill out the function injectMidContentAds that takes one argument, article, which is an object that contains the properties html and blacklist. The function should return an html string with the appended ads.

For the sake of simplicity, the injected ad element can just be an empty div with a class of ad

Simple Example

  const article = {
    html: `
      <article>
        <p>... 210 words ... </p>
        <p>... 430 words ... </p>
        <p>... 650 words ... </p>
        <p>... 802 words ... </p>
      </article>
    `,
    blacklist: [],
  }

  ;
  const result = injectMidContentAds(article);
  console.log(result)

  /*
  <article>
    <p>... 210 words ... </p>
    <p>... 430 words ... </p>

    <div class="ad"></div>

    <p>... 650 words ... </p>
    <p>... 802 words ... </p>
  </article>
  */

Notes About the Project

To make things easy, we bootstrapped the project for you. It contains the main file inject-mid-content-ads.js which is pretty much the only file you'll need to touch.

To get started run yarn in the root directory of this project. (If you don't have yarn you can use npm instead)

There's also a test.js spec file that runs a few tests, if those all pass.. that means you got it working correctly! You can run the test by running yarn test or yarn watch (which will auto run the test file when you save).

In the data folder, you'll find both the articles.js and expected-articles.js. You should always test against articles.js but we provided you the expected result so that you can check what the result should actually look like.

Submission

Init a git repository, complete the test, make your commits locally and then submit a compressed version of the entire code base (including the hidden .git directory).

FAQ About Exercise

  • Can install and use external libraries? โ€“ Absolutely! Use whatever makes you feel comfortable.

  • Who can I send my questions to? โ€“ Stuck on something? Send an email to Lisa ([email protected])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.