Collection Organizer(new)

by Addison Riley

JavaScript

var movies = {
  collectionType: "movies",
	name: "The Avengers, Gardians of the Galaxy, Star Trek",
  type: "Action, Comedy, Sci-fi",
	variable: "Movies"
};
var cars = {
  collectionType: "cars",
	name: "Chevorlet Malibu, Voltzwagon Bug, Honda Civic",
  type: "Muscle, Luxury, Sports",
	variable: "Cars"
};
var videoGames = {
	collectionType: "videoGames",
	name: "Forza 5, Halo 3",
	type: "Racing, First Person Shooter",
	variable: "Video Games"
};
var televisionShows = {
	collectionType: "televisionShows",
	name: "The Office, Jersey Shore",
	type: "Comedy, Reality",
	variable: "Television Shows"
};
var shoes = {
	collectionType: "shoes",
	name: "Jordans, Pegasus",
	type: "Basketball, Running",
	variable: "Shoes"
};

var collections = [movies, cars, videoGames, televisionShows, shoes];

function printCollection(collection) {
    alert(collection.variable + ":" + " " + collection.name + "," + " " + collection.type + ", | ");
}

function view() {
	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, releaseYear, variable){
    var newCollection ={
			collectionType: collectiontype,
			name: name,
  		type: type,
  		releaseYear: releaseyear,
			variable: variable
    }
	collections[collections.length]=newCollection;
}

var userInput = prompt("What collection are you looking for? If you want to see all collections type view. If you are looking to add a collection then type add.", "Type view, add, or search.");
	if (userInput === "view") {
		view()
	}
	else if (userInput === "search") {
		var userChoice = prompt("Please enter the collection you are looking for. Collections: movies, cars, videoGames, televisionShows, shoes", "Type the collection exactly as listed...