Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GasparBonari committed Sep 19, 2023
1 parent 17e7b3b commit 903ab7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions tasks/javascript/easy/sum.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

// TODO: Write a function that returns the sum of two numbers

function sumOfNumbers(...numbers)
{
return numbers.reduce((acc, e) => acc + e);
}

console.log(sumOfNumbers(1, 1))
9 changes: 4 additions & 5 deletions tasks/javascript/medium/tests/library.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ describe("Library", () => {

test("createBook", () => {
const newBook = library.createBook("Title 1", "Author 1");
expect(newBook.title).toBe("Title 2");
expect(newBook.title).toBe("Title 1");
});

test("getBook", () => {
library.createBook("Title 1", "Author 1");
const book = library.getBook(1);
expect(book.title).toBe("Title 2");
expect(book.title).toBe("Title 1");
});

test("updateBook", () => {
library.createBook("Title 1", "Author 1");
const updatedBook = library.updateBook(1, "Title 2", "Author 2");
const updatedBook = library.updateBook(1, "Title 3", "Author 2");
expect(updatedBook.title).toBe("Title 3");
});

test("deleteBook", () => {
library.createBook("Title 1", "Author 1");
const remainingBooks = library.deleteBook(2);
const remainingBooks = library.deleteBook(1);
expect(remainingBooks.length).toBe(0);
});

});

0 comments on commit 903ab7c

Please sign in to comment.