JavaScript
var Orchids = {
collectionType: "Orchids",
name: "Phalenopsis, Vanda, Cymbidium",
type: "Full, rare, ruffled",
like: "Love, dislike, like",
variable: "Orchids"
};
var Plumeria = {
collectionType: "Plumeria",
name: "rubra, obtusa, pudica",
type: "common, hard to find, rare",
like: "Love, like, dislike",
variable: "Plumeria"
};
var Succulents = {
collectionType: "Succulents",
name: "aloe, peyote",
type: "healing, decorative",
like: "like, love",
variable: "Succulents"
};
var Cacti= {
collectionType: "Cacti",
name: "Saguaro, Astrophytum",
type: "tall,prickly",
like: "love, like",
variable: "Cacti"
};
var Palms = {
collectionType: "Palms",
name: "coconut, date",
type: "nut, fruit",
like: "like, love",
variable: "Palms"
};
var collections = [Orchids, Plumeria, Succulents, Cacti, Palms];
function printCollection(collection) {
document.write(collection.variable + ":" + " " + collection.name + "," + " " + collection.type + "," + " " + collection.releaseYear + "|" + " ");
}
function list() {
var collectionsLength = collections.length;
for (var i = 0; i < collectionsLength; i++) {
printCollection(collections[i]);
}
}
function search(type) {
for (var i = 0; i < collections.length; i++){
if (collections[i].collectionType == type){
printCollection(collections[i]);
}
}
}
function add(collectionType, name, type, like, variable){
var newCollection ={
collectionType: collectiontype,
name: name,
type: type,
like: like,
variable: variable
}
collections[collections.length]=newCollection;
}
var userInput = prompt("What collection are you looking for? If you want to see all collections type list. If you are looking to add a collection then type add.", "Type list, add, or search.");
if (userInput === "list") {
list()
}
else if (userInput === "search") {
var userChoice = prompt("Please enter the collection you are looking for. Collections: Orchids, Plumeria,Succulents,...