Skip to content

Instantly share code, notes, and snippets.

View szemate's full-sized avatar

Máté Szendrő szemate

  • London / Budapest
View GitHub Profile
@szemate
szemate / functions-exercises.md
Last active July 22, 2022 11:02
Functions exercises

Functions Exercises

Exercise 1

A club has the following members:

First name Last name Year joined
Jon Snow 2000
Arya Stark 2013
@szemate
szemate / string-comparison.md
Last active March 17, 2022 17:55
String Comparison Exercise

String Comparison Exercise

In the terminal, run the command node and run the following expressions. What are their outputs? Is there anything you didn't expect?

  • "a" < "b"
  • "A" < "B"
  • "a" < "B"
  • "Alice" < "Bob"
  • "alice" &lt; "Bob"
@szemate
szemate / callbacks-exercise.md
Last active March 26, 2022 09:04
Callbacks exercise

Callback function exercise

We are creating a calculator that can do three types of calculation:

  • doubling a number with the double function
  • halving a number with the halve function
  • squaring a number with the square function

Complete the functions so that calculate takes one of the functions that implement an operation and a number as arguments, and returns the result of the calculation.

@szemate
szemate / api-exercise.md
Last active March 20, 2021 21:20
API exercise
@szemate
szemate / http-exercise.md
Last active March 21, 2021 07:29
HTTP exercise

HTTP request-response exercise

1. GET request

Open the Network tab in the browser's Developer Tools, copy-paste http://httpbin.org/get?org=CodeYourFuture&class=ldn7 into the browser's address bar and inspect the following:

  • Request URL: identify the scheme, the host, the endpoint and the query string
  • Request Method
  • Status Code: look it up at https://httpstatuses.com/
  • Request Headers: find the content type
@szemate
szemate / destructuring.js
Last active July 4, 2023 20:49
Destructuring exercises
/**
Exercise 1
Rewrite the code below to use array destructuring instead of assigning each value to a variable.
*/
{
console.log("EXERCISE 1");
let item = ["Egg", 0.25, 12];
@szemate
szemate / testResultGrading.js
Last active October 16, 2021 08:48
JS test result grading exercise
/*
TEST RESULT GRADING
We are writing a program for teachers that helps them grade test results.
The program receives the test results as an array of objects; each object
contains the name of a student and their test score (see below).
1. Print the names and the number (the count) of the students who passed the test (had at least 40 points).
2. Print the average score.
3. Print the name of the student who had the highest score.
@szemate
szemate / storeAccounting.js
Last active September 22, 2022 13:39
JS store accounting exercise
/*
STORE ACCOUNTING
We are writing a program module for an online shop that processes purchases.
The program receives the sold items as an array of objects; each object
contains the name of the item, its price and its category (see below).
1. Print the names and the number (the count) of all sold homeware accessories.
2. Print the total revenue (the sum of the prices of all sold items).
3. Print the average price of the items. Make sure that the price is rounded to 2 decimal points.
@szemate
szemate / node-week1-exercises.md
Last active July 22, 2022 11:03
Node Week1 exercises

Node Week 1 Exercises

Exercise 1

  1. Extract the contents of the zip file into a new directory and open the folder in VSCode.
  2. Initialise a new Node app in the directory. The entry point should be the existing server.js.
  3. Install Express.
  4. Create an Express app in server.js that listens on port 3000.
  5. Create a new request in Postman to make sure that the server is working.
@szemate
szemate / sql-week2-exercise.md
Last active January 29, 2022 15:29
SQL Week 2 Exercise

Node with Postgres Exercise

This exercise requires a working Postgres DB server with the homework database from https://github.com/CodeYourFuture/SQL-Coursework-Week1/tree/main/2-classes-db.

  1. Initialise a new Node/Express web server.
  2. Set up a connection pool to the homework database with node-posgtres.
  3. Create a GET /spends endpoint that returns the list of all spends as a JSON array of objects. Each object should contain the date, description and amount properties.
  4. Create a GET /suppliers endpoint that returns the list of the names of all suppliers as a JSON array of strings. Make sure the response is an array of strings and not an array of objects!
  5. Extend the GET /spends endpont to return a more compete list of spends. Each object should contain the expense_area, expense_type, supplier, date, description and amount properties. The objects should not include any IDs, that is, the tables should be joined together.