Coder Social home page Coder Social logo

test-adeo's Introduction

Javascript developer test

Details: In the following file data.js, there are Countries containing Peoples containing Animals. Some features have been implemented by a previous developer. You need to check if all user stories have been completed. If you find some issues or enhancements, feel free to fork this repository and create a new pull request on this repository.

Requirements

  • All your changes should be in a new branch. You have to open a new pull request to push your work in this repository.
  • No library/modules should be added.
  • Code readability, structure and consistency
  • Tests, and how they are written
  • Usage of comments

User story #1 filter

The customer would like to filter the above lists by animals name and print a formatted list in the console.

Your task: You have to implement a command filter that take in parameter a name of animal or a partial name.

Rules: if an animal name should not match the input pattern, it should be removed from the list. if a people no longer contains animal after the filter, the people should not appear in the result. if a country no longer contains people after the filter, the country should not appear in the result. The order of countries, peoples and animals should be kept intact.

Example :

$ node app.js --filter=ry
# Only animals containing `ry` are displayed.
[
  {
    "name": "Uzuzozne",
    "people": [
      {
        "name": "Lillie Abbott",
        "animals": [
          {
            "name": "John Dory"
          }
        ]
      }
    ]
  },
  {
    "name": "Satanwi",
    "people": [
      {
        "name": "Anthony Bruno",
        "animals": [
          {
            "name": "Oryx"
          }
        ]
      }
    ]
  }
]
$ node app.js --filter=uz
# Only animals containing `Uz` are displayed.
[
  {
    "name": "Dillauti",
    "people": [
      {
        "name": "Philip Murray",
        "animals": [
          {
            "name": "Buzzard"
          }
        ]
      }
    ]
  }
]

User story #2 count

The next goal is to print the counts of People and Animals by counting the number of children and appending it in the name.

Task: You have to implement a new command count that does not take any parameters. It adds a suffix to countries and people by counting their respective direct children. The number of children should appear in square brackets a white space after the name of the country or the people.

Rules: If the count is the only command called, you have to count the initial data.

User story #3 combine filter and count commands

Task: It should be possible to use a command filter and a command count in the same call.

Rules: The count command should add the number of children after the filter was applied.

node app.js --count --filter=ry
node app.js --filter=ry --count
# This two commands should produce the same result
[
  {
    "name": "Uzuzozne [1]",
    "people": [
      {
        "name": "Lillie Abbott [1]",
        "animals": [
          {
            "name": "John Dory"
          }
        ]
      }
    ]
  },
  {
    "name": "Satanwi [1]",
    "people": [
      {
        "name": "Anthony Bruno [1]",
        "animals": [
          {
            "name": "Oryx"
          }
        ]
      }
    ]
  }
]

test-adeo's People

Contributors

sgamidb avatar parmentierchristophe avatar

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.