write a function that takes the array and returns an array of titles:
This commit is contained in:
		
							parent
							
								
									8339f3e8d2
								
							
						
					
					
						commit
						97980c9e3f
					
				|  | @ -1,6 +1,19 @@ | ||||||
| const getTheTitles = function() { | const getTheTitles = function() { | ||||||
| 
 |   const books = [ | ||||||
|  |     { | ||||||
|  |       title: 'Book', | ||||||
|  |       author: 'Name' | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       title: 'Book2', | ||||||
|  |       author: 'Name2' | ||||||
|  |     } | ||||||
|  |   ] | ||||||
|  |   return books.map(function(book){ | ||||||
|  |   return book.title; | ||||||
|  |   }) | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| // Do not edit below this line
 | // Do not edit below this line
 | ||||||
| module.exports = getTheTitles; | module.exports = getTheTitles; | ||||||
|  |  | ||||||
|  | @ -16,3 +16,4 @@ describe('getTheTitles', () => { | ||||||
|     expect(getTheTitles(books)).toEqual(['Book','Book2']); |     expect(getTheTitles(books)).toEqual(['Book','Book2']); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|  | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue