An open API service indexing awesome lists of open source software.

https://github.com/codelikeagirl29/express-drills

A practice project using Express and Node
https://github.com/codelikeagirl29/express-drills

code-climate express express-drills node practice-project

Last synced: about 2 months ago
JSON representation

A practice project using Express and Node

Awesome Lists containing this project

README

          

# Express Drills
_Solution code for Express drills_

[![Maintainability](https://api.codeclimate.com/v1/badges/ba2c05cf2e951cdfb0ef/maintainability)](https://codeclimate.com/github/CodeLikeAGirl29/express-drills/maintainability)

---

## Drills

1. Create a route handler function on the path `/sum` that accepts two query parameters named `a` and
`b` and find the sum of the two values. Return a string in the format "The sum of a and b is c". Note
that query parameters are always strings so some thought should be given to converting them to numbers.

2. Create an endpoint `/cipher`. The handler function should accept a query parameter named `text` and
a one named `shift`. Encrypt the text using a simple shift cipher also known as a [Caesar Cipher](http://practicalcryptography.com/ciphers/caesar-cipher/).
It is a simple substitution cipher where each letter is shifted a certain number of places down the
alphabet. So if the shift was 1 then A would be replaced by B, and B would be replaced by C and C
would be replaced by D and so on until finally Z would be replaced by A. using this scheme encrypt the
text with the given shift and return the result to the client.

3. To send an array of values to the server via a query string simply repeat the key with different
values. For instance, the query string `?arr=1&arr=2&arr=3` results in the query object `{ arr: [ '1', '2', '3' ] }`.
Create a new endpoint `/lotto` that accepts an array of 6 numbers between 1 and 20. The function then
randomly generates 6 numbers between 1 and 20. Compare the numbers sent in the query with the randomly
generated numbers to determine how many match. If fewer than 4 numbers match respond with the string
"Sorry you lose". If 4 numbers match respond with the string "Congratulations, you win a free ticket",
if 5 numbers match respond with "Congratulations! You win $100!". If all 6 numbers match respond with
"Wow! Unbelievable! You could have won the mega millions!".