Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
// Bonfire: Falsy Bouncer | |
// Author: @duggiemitchell | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function bouncer(arr) { | |
var falsyArr = []; | |
var trueArr = arr.filter(Boolean); | |
return (trueArr); |
// 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)); |
// 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(); | |
{ | |
"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", |
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){
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: |
// Bonfire: Mutations | |
// Author: @duggiemitchell | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
//Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array. | |
function mutation(arr) { | |
var strOne = arr[0].toLowerCase(); | |
var strTwo = arr[1].toLowerCase().split(""); | |
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;
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!