Professional Documents
Culture Documents
Brand Wick
Brand Wick
Question - 1
NodeJS: Kanban Board API
{
"id": 2,
"stage": 1,
"title": "Create a new project"
}
It should allow for managing the collection of items in a Kanban Board in the current stage in the following way:
You should complete the given project so that it passes all the test cases when running the provided unit tests. The project by default supports the use of
the SQLite3 database.
1/10
{
"title": "Create a new project"
}
The response code is 201, and when converted to JSON, the response body is:
{
"id": 1,
"stage": 1,
"title": "Create a new project"
}
This adds a new object to the collection with the given properties, id 1, with the stage set to 1.
{
"stage": 2
}
The response code is 200, the stage of item 1 has been updated to 2, and the updated item object is sent in the response body:
{
"id": 1,
"stage": 2,
"title": "Create a new project"
}
{
"stage": 4
}
The response code is 400 with no requirements for the response body.
Question - 2
React: Autocorrection App
Create a basic autocorrection application per the requirements below. The finished application must pass all of the unit tests.
2/10
AutocorrectTextarea is a component that takes a corrections Object that maps strings to their corrections. For example, the object below denotes that
'really' is a correction for 'realy', and 'weird' is a correction of 'wierd':
const corrections = {
'realy': 'really',
'wierd': 'weird',
};
Assume that no value of the corrections object appears as the property in the corrections object.
AutocorrectTextarea renders a textarea element and lets users write text in it.
Assume that the text consists only of words separated by a single space character.
Once a space character is typed, the word preceding it is considered to be complete and must be autocorrected according to the corrections object if a
correction exists.
Initially, the file is filled with boilerplate code. Note the following:
The textarea element must have data-testid="textarea" .
Please note that the component has these data-testid attributes for test cases, and certain classes and ids for rendering purposes. You should not change
them.
Question - 3
JavaScript: Student Record Manipulation
Your implementation of the function will be tested by a provided code stub on several input files. Each input file contains parameters for the function call.
The function will be called with those parameters, and the result of its execution will be printed to the standard output by the provided code. The provided
code prints the properties of the returned object ordered by their names.
The first line contains an integer, n, denoting the number of properties obj has.
Each line i of the n subsequent lines (where 0 ≤ i < n) contains two space-separated values. The first of them is a string denoting the property of obj, and
the second one is the value of that property.
The last line contains string values for modification for obj in the format {operation} {prop} {newValue}.
Sample Case 0
3
name John
lastName Bliss
city Florida
edit city Seattle
Sample Output
city Seattle
lastName Bliss
name John
Explanation
3/10
In this test, obj has 3 properties: name, lastName, and city. The property to edit is city, so the returned object literal contains the value 'Seattle' for the
property city, while the other two properties are the same as in obj.
Sample Case 1
3
name John
lastName Bliss
city Florida
delete city
Sample Output
lastName Bliss
name John
Explanation
In this test, obj has 3 properties: name, lastName, and city. The property to delete is city, so the returned object literal contains properties name and
lastName but does not contains city as that has been deleted.
Sample Case 2
3
name John
lastName Bliss
city Florida
edit abc Tor
Sample Output
city Florida
lastName Bliss
name John
Explanation
In this test, obj has 3 properties: name, lastName, and city. The property to edit is 'abc', which does not exist, so the returned object literal is the same as
the input.
Question - 4
React: User Management
There is a partially completed React application with the HTML template built and ready, and certain core React functionalities are implemented. Complete
the React application as shown in order to pass all the unit tests.
4/10
The application has 2 components:
1. The UserList.js which has the user list table which includes edit/delete buttons as actions against the row.
2. The AddEditUser.js which renders the form to enter the user details to be added or edited.
1. AddEditUser.js
The initial view must not display any alert.
Clicking the Cancel button should:
do nothing if the fields are empty.
clear all the fields and reset them to empty.
clear the validation alert (if any).
after clicking the Edit button, discard the changes in the form and add the original user values back to the table.
Clicking the Add/Edit button should:
add field values as a row to the table with no validation alert and reset the form fields to empty.
after clicking the Edit button, add the user's updated data to the table or show a validation alert in case of any errors.
2. UserList.js
The initial view must display an empty list with no rows.
Clicking the Delete button should delete the corresponding row from the table.
Clicking the Edit button should populate the form fields where updates can be made.
The following data-testid attributes are required in the component for the tests to pass:
Component Attribute
Please note that the component has data-testid attributes for test cases and certain classes and ids for rendering purposes. They should not be changed.
Question - 5
React: Date API
In the given single page React project, a button click prompts an HTTP GET request to an API endpoint that returns a date as its API response. Complete the
project so it displays the current day, month, and year after clicking the button. Model the implementation after the instructions below.
Certain core React functionalities have already been implemented. Complete the React application in order to pass all the unit tests.
Demo
Link to an animated GIF
5/10
Scroll sideways below to explore the screenshots. Clicking each screenshot opens it in a new window.
Specifications
Component flow diagram of the application is as follows:
6/10
The project uses React Material UI as a design framework. API docs are available here and can be used as a reference.
Question - 6
NodeJS: TypeORM Stock Trades API
In this challenge, your task is to implement a simple REST API to manage a collection of stock trades.
{
"id":1,
"type": "buy",
"user_id": 23,
"symbol": "ABX",
"shares": 30,
"price": 134,
"timestamp": 1531522701000
}
You are provided with the implementation of the Trade model in a project using TypeScript and TypeORM. The task is to implement the REST service that
exposes the /trades endpoint, which allows for managing the collection of trade records in the following way:
You should complete the given project so that it passes all the test cases when running the provided unit tests. The project by default supports the use of
the SQLite3 database with the TypeScript based TypeORM module.
7/10
Each route added to the routes.ts file should be of type `ApplicationRequest` which is defined below:
interface ApplicationRequest {
path: string; // The URL of the request
action: (req: Request, res: Response, next?: NextFunction) => any // The middleware function to call
method: RequestMethod // The HTTP Method of the request. This is of ENUM type.
}
enum RequestMethod {
GET = 'get',
POST = 'post',
PUT = 'put',
PATCH = 'patch',
DELETE = 'delete',
}
{
"type": "buy",
"user_id": 1,
"symbol": "AC",
"shares": 28,
"price": 162,
"timestamp" : 1591514264000
}
The response code is 201, and when converted to JSON, the response body is:
{
"id": 1,
"type": "buy",
"user_id": 1,
"symbol": "AC",
"shares": 28,
"price": 162,
"timestamp" : 1591514264000
}
This adds a new object to the collection with the given properties and id 1.
[
{
"id": 1,
"type": "buy",
"user_id": 1,
"symbol": "AC",
"shares": 28,
"price": 162,
"timestamp" : 1591514264000
},
{
"id": 2,
"type": "sell",
"user_id": 1,
"symbol": "AC",
"shares": 28,
8/10
"price": 162,
"timestamp" : 1591514264000
}
]
{
"id": 1,
"type": "buy",
"user_id": 1,
"symbol": "AC",
"shares": 28,
"price": 162,
"timestamp" : 1591514264000
}
If an object with id 1 doesn't exist, then the response code is 404 with the response body having the text `ID not found`
Question - 7
JavaScript: Inventory List
Your function implementation will be tested by a stubbed code on several input files. Each input file contains parameters for the function calls. The results
of their execution will be printed to standard output by the provided code. The stubbed code joins the strings returned by the getList function by a comma
and prints to the standard output. If getList returns an empty array, the stubbed code prints 'No Items'.
Constraints:
The size of the collection will not exceed 10 at any point.
All names passed to add(name) and remove(name) are non-empty.
In the first line, there is an integer, n, denoting the number of operations to be performed.
Each line i of the n subsequent lines (where 0 ≤ i < n) contains space-separated strings such that the first of them is a function name, and the remaining
ones, if any, are parameters for that function.
Sample Case 0
5
add Shirt
add Trouser
getList
remove Shirt
getList
9/10
Sample Output
Shirt,Trouser
Trouser
Explanation
Items 'Shirt' and 'Trouser' are added by the add function. Then, getList is called, and the result is printed. Item 'Shirt' is removed by calling the remove
function. Finally, getList is called, and the result is printed.
Sample Case 1
3
add Shirt
remove Trouser
getList
Sample Output
Shirt
Explanation
Item 'Shirt' is added by the add function. Then, remove is called with 'Trouser'. Since 'Trouser' does not exist, nothing happens. Finally, getList is called,
and the result is printed.
10/10