Harjoitellaan JavaScript kielen perusteita. Tarkoituksena on opiskella rakenteita, joita tarvitaan kun tehdään REST API sovellus Express-frameworkillä. Tässä käsitellään assosiatiivista arraytä, koska se muistuttaa tietokannan taulua.
- Luo assosiatiivinen array nimeltään bookArray, jossa on samat kentät kuin book-taulussa kts. https://peatutor.com/databases/library.php
- Tulosta konsolille mikä luomasi taulun "tietotyyppi" on (käytä JavaScriptin typeof-funktiota)
- Tulosta konsolille koko bookArrayn sisältö
- Tulosta konsolille bookArrayn ensimmäinen rivi
- Tulosta konsolille ensimmäisen kirjan nimi
- Tulosta konsolille arrayn rivien määrä
- Tulosta konsolille kaikkien kirjojen nimet
Let's practice the basics of JavaScript. The goal is to learn structures needed when building a REST API application using the Express framework. Here, we will work with an associative array because it resembles a database table.
- Create an associative array named `bookArray` with the same fields as the `book` table (see: https://peatutor.com/databases/library.php).
- Print to the console the "data type" of the table you created (use JavaScript's `typeof` function).
- Print the entire content of `bookArray` to the console.
- Print the first row of `bookArray` to the console.
- Print the name of the first book to the console.
- Print the number of rows in the array to the console.
- Print the names of all books to the console.