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...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.