Hi,
im trying to write code for someone to reserve a book, the books are stored in an array, and there are other arrays to show which books have been reserved or not..
the user will enter the index number of a book to reserve, the program then searches through the array and then reserves the book by editing the array so the book is no longer available.
im struggling with the code, can anyone give any pointers please?
CODE
var borrowedArray = ['-', '-', '-', 'rs-14', '-', '-'];
var reservedArray = ['-', 'ly-44', '-', '-', '-', '-'];
var readerNameArray = ['ly-44', 'mr-7', 'rs-14', 'al-15', 'pn-44', 'wk-46'];
var indexArray = ['0', '1', '2', '3', '4', '5'];
document.write('' + '<BR>' + 'What would you like to do?' + '<BR>')
document.write('1. Reserve a book' + '<BR>')
document.write('2. Borrow a book' + '<BR>')
readerIndex= window.prompt('Enter 1 or 2 to select','');
if (readerIndex == 1)
document.write('please enter the index number of the book you wish to reserve' + '<BR>')
readerIndex = 0;
readerIndex = window.prompt('Enter a number 0 - 6 to select','');
if (readerIndex > 6)
{
document.write('No such book!')
}
if (readerIndex[bookStatus] == 'reserved' || 'on loan')
{
document.write('you cannot reserve that book')
}
else
{
document.write('Book reserved')
}
i know this is completely wrong, as i think i need to use a for loop to loop through the array,
can anyone give an example of how to edit an array?