# Title Missing From Book Cover

**URL:** <https://forum.kirupa.com/t/title-missing-from-book-cover/644128>\
**Category:** Uncategorized\
**Created:** [September 9, 2020, 4:04pm UTC](https://forum.kirupa.com/t/title-missing-from-book-cover/644128 "2020-09-09T16:04:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Stern](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/john_stern/32/12050_2.png) [@John\_Stern](https://forum.kirupa.com/u/John_Stern)\
**Post date:** [September 9, 2020, 4:04pm UTC](https://forum.kirupa.com/t/title-missing-from-book-cover/644128/1 "2020-09-09T16:04:07Z")

</div>

```auto
var library = [ //array of 3 objects
{	title:”I Know Why The Caged Bird Sings”,
	author:”R. Michener”,
	stars:4 },
	{	title:”Alaric the Goth”,
	author:"Boin",
	stars:4 },
	{	title:”Caesar Invades Gaul”,
	author:”Goldsworthy”,
	stars:4 }
	];

fill(140, 107, 7); // brown bookshelf
rect(0,120,width,20);
for(var i = 0; i < 3; i++) {
    fill(100 + 100*i, 200, 100 + 100*i); // 3 book covers different colors
    rect(20 + 110*i,20,90,100);
    textSize(15);
    fill(93, 105, 25);
	text(library.title[i],20 + 110*i,60,90,40,80,30);
}

```

I thought this code would place the titles of the books on to the book covers in the top 1/3 of the cover but no - nothing happens - I think the code looks OK so I don’t see where I am going wrong

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [September 9, 2020, 4:07pm UTC](https://forum.kirupa.com/t/title-missing-from-book-cover/644128/2 "2020-09-09T16:07:04Z")

</div>

I’m seeing some weird forum formatting in the code which makes me think some of the missing `*` from before (and now) might be because you’re not using the forum code formatting to format your code which causes the code to instead format the text as italics instead of showing the multiplication symbols 😛 I’m going to edit your post to fix those things, but in the future you can wrap your code with triple back ticks (`````) to fix this…

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [September 9, 2020, 4:09pm UTC](https://forum.kirupa.com/t/title-missing-from-book-cover/644128/3 "2020-09-09T16:09:42Z")

</div>

The error with the code is this line

```
text(library.title[i],20 + 110*i,60,90,40,80,30);

```

The problem here is that library is the array, not title. Its the array you want to use the square brackets with - to get the i’th value in that array. title is the property of that i’th value. What it should be is:

```
text(library[i].title,20 + 110*i,60,90,40,80,30);
```

---

<div class="post-metadata">

**Author:** ![John\_Stern](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/john_stern/32/12050_2.png) [@John\_Stern](https://forum.kirupa.com/u/John_Stern)\
**Post date:** [September 9, 2020, 5:56pm UTC](https://forum.kirupa.com/t/title-missing-from-book-cover/644128/4 "2020-09-09T17:56:31Z")

</div>

so this code at least gives me a bookshelf with 3 books each a different color

fill(140, 107, 7); // brown bookshelf  
rect(0,120,width,20);  
for(var i = 0; i \< 3; i++) {  
fill(100 + 100_i, 200, 100 + 100_i); // 3 book covers different colors  
rect(20 + 110\*i,20,90,100);  
}

but when I add the complete code that I thought would place the title on the books (btw the complete code includes fixing my previous error of the misplaced [i] in the line

text(library[i].title,20 + 110\*i,60,90,40,80,30);

such that the code looks like

var library = [ //array of 3 objects  
{ title:”I Know Why The Caged Bird Sings”,  
author:”R. Michener”,  
stars:4 },  
{ title:”Alaric the Goth”,  
author:“Boin”,  
stars:4 },  
{ title:”Caesar Invades Gaul”,  
author:”Goldsworthy”,  
stars:4 }  
];

fill(140, 107, 7); // brown bookshelf  
rect(0,120,width,20);  
for(var i = 0; i \< 3; i++) {  
fill(100 + 100_i, 200, 100 + 100_i); // 3 book covers different colors  
rect(20 + 110_i,20,90,100);  
textSize(15);  
fill(93, 105, 25);  
text(library[i].title,20 + 110_i,60,90,40,80,30);  
}

well now my bookshelf and books disappear to say nothing of the titles showing !  
Yikes ! I am going backwards !
