From 936e35a2dbfd5accc9ae42328d522f971e0f6fd6 Mon Sep 17 00:00:00 2001 From: ibrahim oke Date: Thu, 9 Nov 2023 11:23:02 +0100 Subject: [PATCH 1/3] added my name --- Contributors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contributors.md b/Contributors.md index a9e9ede..9f17107 100644 --- a/Contributors.md +++ b/Contributors.md @@ -5,4 +5,4 @@ 1. icodejsx 2. ogbon(Segun Amosu) 3. Solomon Eseme - +4. Ibrahim oke From 012c647778c52e39aec5b8e480cc39bdd6fd4d42 Mon Sep 17 00:00:00 2001 From: Dev_hibee <122791179+hibee-code@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:28:06 +0100 Subject: [PATCH 2/3] Create lexicalScope.md --- lexicalScope.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lexicalScope.md diff --git a/lexicalScope.md b/lexicalScope.md new file mode 100644 index 0000000..2e8f985 --- /dev/null +++ b/lexicalScope.md @@ -0,0 +1,20 @@ +# Lexical Scope + +lexical scope is refer to as the location of the function in the source code, which means that a function can access variables from its own scope as well as from the scopes of its outer (enclosing) functions. It also refer to as static scope. + +some code example to better explain lexical scope + +var a = 10; // variable a assigned to 10 + +var func = function (){ // outermost function + var b = 20; + console.log("a and b is accessible (outer):", a, b); + var innerFunc= function (){ // innermost function + var c = 30; + console.log("a and b and c is accessible (innner):", a, b, c); + } + innerFunc(); + return; +} +func(); // invoke function func +console.log("only a is accessible (global):", a); From 97b1eb1f5f8bda05bcf77abc3d6e4ae7cb61bc0c Mon Sep 17 00:00:00 2001 From: Dev_hibee <122791179+hibee-code@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:44:12 +0100 Subject: [PATCH 3/3] Create RESTAPI assignment --- RESTAPI assignment | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 RESTAPI assignment diff --git a/RESTAPI assignment b/RESTAPI assignment new file mode 100644 index 0000000..b0b53f0 --- /dev/null +++ b/RESTAPI assignment @@ -0,0 +1,41 @@ +let book = [ +{id:1, title: "introduction to REST API", author: "James Bennie"}, +{id:2, title: "introduction to Javascript", author: "Jonas schmdtman"} +]; + +//GET METHOS: all books +app.get("/books", (req, res) => ( +res.send(200).json(books) +)}; +//GET METHOD: a specific book bt ID + +app.get("/book/:id", (req, res) => ( +const { id } = req.params; +const book = books.findById(id); +res.send (200).json(books); +)}; + +//POST METHOD: Create a new book + +app.post("/books", (req, res) => { +const newBook = req.body; +books.push(newBook) +res.send(201) +}); + +//PuT METHOD: Create a new book + +app.put("/books", (req, res) => { +const { id } = req.params; +const updateBooks = req.body; +const index = book.findIndex(id); +res.send(201) +}); + +//DELETE METHOD: Create a new book + +app.delete("/books", (req, res) => { +const { id } = req.params; +books = book.find.filter(id); +res.sned(200) +});