Join 117,607 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,456 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
Use an If statement to check the value of the array and depending on what it finds, output the word "reserved" or "on shelf" to the document, in place of the array output that you are currently getting.
What specifically do you not understand about parallel arrays?
is there something i need to write in it when checking if there is any value in the array? as you can see there are only 2 index's in the arrays currently reserved or borrowed..later on the other indexes will be filled by a user reserving or borrowing a book
Hey, im still trying to tackle this one, just wondering if anyone can offer advice as to what i have so far?
CODE
if (readerPassword == readerPasswordArray[count]) { document.write('<BR>'+'<BR>'+'Welcome to the catalog'+'<br>'+'================='+' <BR>' )
for (var index = 0; index < bookArray.length; index++) var shelfArray = new Array (if (borrowedArray[index] == ('-')) { shelfArray[index] = ('onshelf') } else { if (borrowedArray[index] != ('-')) { shelfArray[index] = ('borrowed') } })
document.write ( index + ' --- ' +bookArray[index] + '---------' + authorArray[index] +' ----------' + shelfArray[index] +'<br>' ); '<br>' document.write ('What would you like to do?'+ '<br>' + '<br>') document.write('1. Reserve a Book'+ '<br>') document.write('2. Borrow a Book'+ '<br>')
var borrowedArray = ['-', '-', '-', 'rs-14', '-', '-'];
// Array Of Book Reservation Information
var reservedArray = ['-', 'ly-44', '-', '-', '-', '-'];
what I want to happen is where the borrowed array or reserved array have a '-' i want the document to write on shelf, and where there is a reader name eg. 'ly-44' the words resered or borrow to be written. I have tried if statements galore, but to no avail.
Im only a newbie so if its really obvious at how its done please dont shout at me lol!!
Hey, im still trying to tackle this one, just wondering if anyone can offer advice as to what i have so far?
CODE
if (readerPassword == readerPasswordArray[count]) { document.write('<BR>'+'<BR>'+'Welcome to the catalog'+'<br>'+'================='+' <BR>' )
for (var index = 0; index < bookArray.length; index++) var shelfArray = new Array (if (borrowedArray[index] == ('-')) { shelfArray[index] = ('onshelf') } else { if (borrowedArray[index] != ('-')) { shelfArray[index] = ('borrowed') } })
document.write ( index + ' --- ' +bookArray[index] + '---------' + authorArray[index] +' ----------' + shelfArray[index] +'<br>' ); '<br>' document.write ('What would you like to do?'+ '<br>' + '<br>') document.write('1. Reserve a Book'+ '<br>') document.write('2. Borrow a Book'+ '<br>')
var borrowedArray = ['-', '-', '-', 'rs-14', '-', '-'];
// Array Of Book Reservation Information
var reservedArray = ['-', 'ly-44', '-', '-', '-', '-'];
what I want to happen is where the borrowed array or reserved array have a '-' i want the document to write on shelf, and where there is a reader name eg. 'ly-44' the words resered or borrow to be written. I have tried if statements galore, but to no avail.
Im only a newbie so if its really obvious at how its done please dont shout at me lol!!
I hope I have made some sense?
kelbly
my tutor said the same about the guide on page 25, but i still havent got a clue lol!
I can do it by creating an array to write it out, but I have manualy written the array, and i thought by way the question has been asked means we have to create a code to work out the status of the book.
But then you look at the clue, and they have manually written in the month names, so I am totally lost!! I feel stupid if i ask the tutor again!!
I can do it by creating an array to write it out, but I have manualy written the array, and i thought by way the question has been asked means we have to create a code to work out the status of the book.
But then you look at the clue, and they have manually written in the month names, so I am totally lost!! I feel stupid if i ask the tutor again!!
ive wasted enough time, i just created a new array saying the status of the book, i know we need to go back to these arrays in the next question, so if its wrong ill try sort it then..probably is wrong knowing me
I can do it by creating an array to write it out, but I have manualy written the array, and i thought by way the question has been asked means we have to create a code to work out the status of the book.
But then you look at the clue, and they have manually written in the month names, so I am totally lost!! I feel stupid if i ask the tutor again!!
cant drag myself away from this question, its doing my head in..
there must be some way of using an if statement to search through the array until it finds the username and display reserved or borrowed, depending on where the reader name is in the index..
anybody doing the same course got any pointers? i dont want to be given the answer as i want it to be my own work..just a gentle nudge in the right direction would be appreciated lol
I can do it by creating an array to write it out, but I have manualy written the array, and i thought by way the question has been asked means we have to create a code to work out the status of the book.
But then you look at the clue, and they have manually written in the month names, so I am totally lost!! I feel stupid if i ask the tutor again!!
cant drag myself away from this question, its doing my head in..
there must be some way of using an if statement to search through the array until it finds the username and display reserved or borrowed, depending on where the reader name is in the index..
anybody doing the same course got any pointers? i dont want to be given the answer as i want it to be my own work..just a gentle nudge in the right direction would be appreciated lol
Hi, I see quite a few of us stuck with this. I'm stuck as well at the same point and I found the examples from units very unhelpful, I've studied them all last night and really can't associate them with this question. Hope we'll get it done by next week... And I just don't want to move to the next question before sorting this out, because we'll need this script to be done for next part.. Tried setting up new arrays but still can't get correct output nowhere near..
Hi the best way to tackle this is to Write a a function that checks both arrays and returns the correct value. You won't then need to create another array. That's how i completed it anyway.
The first part of function could go something like this
CODE
function bookStatus()
if (reservedArray[count] == '-' && borrowedArray[count] == '-')
return 'on shelf'
then just create more if else statements to work the possible variations.