Deviopath › Node.js

Status Code Text

Easy · HTTP

Node ships a table of reason phrases in http.STATUS_CODES, for example http.STATUS_CODES[404] is "Not Found".

Write a function statusText(code) that returns the same text as Node for these codes: 200, 201, 204, 301, 304, 400, 401, 403, 404, 500.

For any other code return "Unknown" (Node knows many more codes, but here we only use this list).

Next: Bytes to Hex