From 341661a10090b5ccba0fbd905b81bcc7b3cad8a5 Mon Sep 17 00:00:00 2001 From: Cody Loyd Date: Thu, 11 Apr 2019 11:37:33 -0500 Subject: [PATCH] add titles exercise --- getTheTitles/README.md | 26 ++++++++++++++++++++++++++ getTheTitles/getTheTitles.js | 5 +++++ getTheTitles/getTheTitles.spec.js | 19 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 getTheTitles/README.md create mode 100644 getTheTitles/getTheTitles.js create mode 100644 getTheTitles/getTheTitles.spec.js diff --git a/getTheTitles/README.md b/getTheTitles/README.md new file mode 100644 index 0000000..20595f2 --- /dev/null +++ b/getTheTitles/README.md @@ -0,0 +1,26 @@ +# Get the Titles! + +You are given an array of objects that represent books with an author and a title that looks like this: + +```javascript +const books = [ + { + title: 'Book', + author: 'Name' + }, + { + title: 'Book2', + author: 'Name2' + } +] +``` + +your job is to write a function that takes the array and returns an array of titles: + +```javascript +getTheTitles(books) // ['Book','Book2'] +``` + +## Hints + +- You should use a built-in javascript method to do most of the work for you! diff --git a/getTheTitles/getTheTitles.js b/getTheTitles/getTheTitles.js new file mode 100644 index 0000000..2b52aa0 --- /dev/null +++ b/getTheTitles/getTheTitles.js @@ -0,0 +1,5 @@ +const getTheTitles = function() { + +} + +module.exports = getTheTitles; diff --git a/getTheTitles/getTheTitles.spec.js b/getTheTitles/getTheTitles.spec.js new file mode 100644 index 0000000..3bef46c --- /dev/null +++ b/getTheTitles/getTheTitles.spec.js @@ -0,0 +1,19 @@ +let getTheTitles = require('./getTheTitles') + +describe('getTheTitles', function() { + const books = [ + { + title: 'Book', + author: 'Name' + }, + { + title: 'Book2', + author: 'Name2' + } + ] + + it('gets titles', function() { + expect(getTheTitles(books)).toEqual(['Book','Book2']); + }); + +});