done getTheTitles
This commit is contained in:
parent
be6251ecc4
commit
bccd35b40d
|
@ -1,5 +1,13 @@
|
||||||
const getTheTitles = function() {
|
const getTheTitles = function(books) {
|
||||||
|
|
||||||
|
let titleArray = [];
|
||||||
|
|
||||||
|
for (i = 0; i < books.length; i++) {
|
||||||
|
// console.log(books[i].title);
|
||||||
|
titleArray.push(books[i].title);
|
||||||
|
}
|
||||||
|
console.log(titleArray);
|
||||||
|
return titleArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = getTheTitles;
|
module.exports = getTheTitles;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<script src="test.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,26 @@
|
||||||
|
function getTheTitles(books) {
|
||||||
|
|
||||||
|
let titleArray = [];
|
||||||
|
|
||||||
|
for (i = 0; i < books.length; i++) {
|
||||||
|
// console.log(books[i].title);
|
||||||
|
titleArray.push(books[i].title);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(titleArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
//given data
|
||||||
|
const books = [
|
||||||
|
{
|
||||||
|
title: "Book",
|
||||||
|
author: "Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Book2",
|
||||||
|
author: "Name2"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
getTheTitles(books);
|
||||||
|
|
Loading…
Reference in New Issue