Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 69 additions & 10 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@


/**
/**
* RAP NAME GENERATOR
* The user will insert their first name and on click receive one of several
* possible outputs (i.e. Jill).
Expand All @@ -13,20 +11,81 @@
**/

function Generator() {

/* Name Arrays: Customize names to change possible output */
this.last_names = ['the Chef', 'Digital', 'Wise', 'Knight', 'Wrecka', 'the Genius', 'the Zoo Keeper', 'the Monk', 'the Scientist', 'the Disciple', 'the Darkman', 'Pellegrino', 'the Ill Figure', 'Rocks The World', 'the Baptist',];
this.last_names = ['the Chef', 'Digital', 'Wise', 'Knight', 'Wrecka', 'the Genius', 'the Zoo Keeper', 'the Monk', 'the Scientist', 'the Disciple', 'the Darkman', 'Pellegrino', 'the Ill Figure', 'Rocks The World', 'the Baptist'];
this.first_names = ['Inspectah', 'Masta', 'Poppa', 'Five Foot', 'Ghostface', 'Old Dirty'];

}

/* need something for initials like A.B. */
Generator.prototype.toInitial = function(name) {
return name.split('').join('.').toUpperCase()+'.';
};

//Add your codez here
/* need something for capital name */
Generator.prototype.toCapital = function(name) {
return name.toUpperCase();
};

/* need something for lower name */
Generator.prototype.toLower = function(name) {
return name.toLowerCase();
};

$(document).ready(function() {
/* need something for end of name */
Generator.prototype.toEnd = function(name) {
var last_name = this.last_names[Math.floor(Math.random() * this.last_names.length)];
return name + ' ' + last_name;
};

/* need something for beginning of name */
Generator.prototype.toBeginning = function(name) {
var first_name = this.first_names[Math.floor(Math.random() * this.first_names.length)];
return first_name + ' ' + name;
};

var engine = new Generator;
//Add your codez here
/* need something for creating the rap name */
Generator.prototype.createName = function(name) {
var randomSelection = Math.floor(Math.random() * 7);
switch (randomSelection) {
case 0:
return this.toEnd(name);
break;
case 1:
return this.toBeginning(name);
break;
case 2:
return this.toEnd(this.toInitial(name));
break;
case 3:
return this.toBeginning(this.toInitial(name));
break;
case 4:
return this.toEnd(this.toCapital(name));
break;
case 5:
return this.toBeginning(this.toCapital(name));
break;
case 6:
return this.toEnd(this.toLower(name));
break;
case 7:
return this.toBeginning(this.toLower(name));
break;
}
}

$(document).ready(function() {
var engine = new Generator;
$('#enter').click(function() {
if ($('#user-input').val() != undefined) {
$('.error').hide();
var origin = $('#user-input').val();
var rapName = engine.createName(origin);
$('.response').text(rapName).show();
}
else {
$('.error').show();
$('.response').hide();
}
})
});