-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBookManagement.js
More file actions
48 lines (40 loc) · 842 Bytes
/
BookManagement.js
File metadata and controls
48 lines (40 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
*
*/
var books=[]
var input=prompt("Which operation You want to perform[add|delete|list|exit]:")
while(input!="exit"){
if(input=="add"){
addBook();
}
else if(input=="list"){
listBooks();
}
else if(input=="delete"){
deleteBook();
}
else{
console.log("Enter valid option");
}
input=prompt("What operation You Want to Perform[add|delete|list|exit]: ")}
function addBooks(){
var newBook=prompt("Enter Name of the Book:")
books.push(newBook);
}
function listBooks(){
console.log("List of Available Books:");
for(book of books){
console.log(book);
}
}
function deleteBook(){
var name=prompt("Enter Book Name to delete:")
var index=books.indexOf(name)
if(index==-1){
console.log("specified book is not available");
}
else{
books.splice(index,1)
console.log("Specified Book Deleted");
}
}