Skip to content

Instantly share code, notes, and snippets.

View duggiemitchell's full-sized avatar
🏠
Working from home

Erica Edge duggiemitchell

🏠
Working from home
View GitHub Profile
# Pig Latin
Translate the provided string to pig latin.
Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an "ay".
If a word begins with a vowel you just add "way" to the end.
function translate(str) {
var RegEx = /[aeiouAEIOU]/;
var latinTranslation ="";
var vowelIndex ="";
if (str[0].match(RegEx)) {
@duggiemitchell
duggiemitchell / ArrayArchipalaego.js
Created January 17, 2016 02:18
Two-Dimensional Arrays
Check out the following setup. Enter a line of code that declares a variable called infant and uses the array eightiesMovies to access the word "Baby".
var movie1 = [16, "Candles"];
var movie2 = [3, "Men", "and", "a", "Baby"];
var eightiesMovies = [movie1, movie2];
> var infant = eightiesMovies[4];
____
Now alert a string with the full title of the first movie in the eightiesMovies array, but only using the eightiesMovies variable to access the correct values. Use the concatenation operator to unite the words into one string, and remember to be attentive to necessary whitespace!

The people at the Hoover Dam have called you back, and would like a program that shows what happens when only the even numbered turbines are turned on. And they want it all in just one for loop.

With a set of complex conditional statements inside the loop, construct a way to only turn on even numbered turbines. Remember our power output situation:

Generators 1 through 4 produce 62 MW. Generators 5 through 19 produce 124 MW. The output should follow this format:

Generator #1 is off. Generator #2 is on, adding 62 MW, for a total of 62 MW!

Back at Death Valley, scientists could see that the Sheep Situation would quickly get out of control. They have decided that, for any month the population climbs above 10000, half of the sheep will be sent away to other regions.

Inside our for loop, insert an if statement that:

Removes half of the sheep population if the number of sheep rises above 10000. Prints the number of sheep being removed to the console in the following format: Removing <number> sheep from the population.

var numSheep = 4;
var monthsToPrint = 12;
@duggiemitchell
duggiemitchell / Where-art-thou.js
Last active January 13, 2016 21:35
Where Art Thou
Create a function that takes in two arguments and iterates through an array of objects (first argument) and returns an array of objects that have matching properties and values pairs of the second argument. The property and value of the source object must be present in the collection variable in order to be included in the returned array.
Given these variables:
var collection = [ { first: "Romeo", last: "Montague" },
{ first: "Mercutio", last: null },
{ first: "Tybalt", last: "Capulet" } ];
var source = [{last: "Capulet"}];
@duggiemitchell
duggiemitchell / bonfire-Diff-Two-Arrays.js
Last active January 3, 2016 00:21
Compare Differences in Arrays using filter & indexOf - Javascript
At our meetup today, @kileyDowling pair programmed with me and it was... different. But I heard having someone peek over your shoulder whilst solving an algorithm is both helpful and a real world example of coding in the wild. The particular challenge of the day was to create function comparing two arrays with different values, and returning a new array containing unique values.
My working solution was close, but not quite returning the right answer. Here is the function:
function diff (arr1, arr2) {
var newArr = [];
return newArr;
}
The solution I created before meeting today used the filter() funtion and indexOf() methods and while on some level filtering the function, the results were not quite what I was hoping for:
@duggiemitchell
duggiemitchell / quoteme.readME.md
Last active December 24, 2015 16:49
Random Quote Generator using jQuery Event Handlers

Random Quote Generator

First create arrays as global variables. I was informed global variables should be avoided for they can cause problems, especially in a project with concurrency. But seeing this project is fairly simple, we can make this exception. We'd obviously like to have more quotes to choose from, but if you want to see the project in action check it out on my portfolio.

var happyQuotes = ["I am a happyQuote!","I too am a happyQuote!;]; var lostQuotes = [" I am lost!"," I too am lost!";`"]; var scaredQuote = ["I am sooo scared!" , "I second that... being scared!"]; var sadQuote = [```"Fear is the mind killer.","...doesn't stop my fear"];

getRandomNumberNumber accepting min and max as arguments function getRandomNumber(min, max){

@duggiemitchell
duggiemitchell / config.json
Created December 11, 2015 16:45 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
// Bonfire: Where do I belong
// Author: @duggiemitchell
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(arr, num) {
arr.push(num);
arr.sort();
// Bonfire: Seek and Destroy
// Author: @duggiemitchell
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
var argCombo = arr.slice.call(arguments);
console.log(argCombo.splice(0,1));