# Bonfire: Mutations

This challenge took me so ridiculously long!

The Challenge:

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.

For example, `["hello", "Hello"]`, should return true because all of the letters in the second string are present in the first, ignoring case.

The arguments `["hello", "hey"]` should return false because the string “hello” does not contain a “y”.

Use .indexOf()

The Solution:

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17``` ```function mutation(arr) { var firstArr = arr[0].toLowerCase().split(''); var secondArr = arr[1].toLowerCase().split(''); for (var i = 0; i < secondArr.length; i++) { var positive = firstArr.indexOf(secondArr[i]); if (positive === -1) { return false; }; }; return true; } mutation(["hello", "hey"]);```

To find the solution to this challenge, I first needed to compare all the letters of the two arguments with each other. To separate the letters of each word, I used .split(”) (see lines 2 and 3).

Since the second argument is shorter than the first, I only wanted to loop through the length of the second argument, in this case “hey”.

Using .indexOf(), I checked each letter of “hey” (secondArr) to see if the letters are in “hello” (firstArr). If the letter from secondArr is NOT in firstArr, the value of -1 will be saved to the variable positive.

# Easy Counting Question | Hackerrank

Completing a sample easy challenge from Hackerrank

Challenge:

Write a function called countUp(start) that takes a number (start) and counts upwards 10 times with all the words separated by “then”.

For example:

countUp(10);

>> 11 then 12 then 13 then 14 then 15 then 16 then 17 then 18 then 19 then 20

The Solution:

```function countUp(start) {
start = start + 1;
var string = "";
process.stdout.write((start) + string);
for (var i = start+1; i < (start + 10); i++) {
string = process.stdout.write(" then " + i);
}
}```

`process.stdout.write ` is equivalent to Ruby’s ‘print’ . It removes the line break.

This was a really hard coding challenge, even though it was labeled ‘Easy’.

I knew I had to print out numbers in sequence, incrementing by 1 so I decided to use a ‘for’ loop. Getting all the numbers to print out and then adding ” then ” to the end was easy. Removing the last ” then ” was hard.

I first was trying to loop adding ” then ” after the number like this:

`4 then 5 then 6 then 7 then 8 then`

But then my answer ends with the word ” then ” and that’s incorrect. So next I tried to just count up to 9 numbers and add the 10th number to the end of the string, but I kept getting an error. After much time had passed, I added ” then ” before the number so that my loop looked like this:

`then 5 then 6 then 7 then 8`

Finally, I added the ‘start’ value +1 to the beginning of the string to pass the tests.

`4 then 5 then 6 then 7 then 8`

# FreeCodeCamp in Atlanta

I organized the Atlanta FreeCodeCamp meeting this past Saturday, gathering fellow FreeCodeCampers together to code and pair program. Just saw this post this morning where the Founder of FreeCodeCamp, Quincy Larson, used my picture in his LinkedIn post linking to an answer on Quora. I am ecstatic. I am SO impressed with how involved the founder is with the users of his program. Thanks for promoting the Atlanta group!

See the Quora post here: “I suck at programming but I love it. What should I do?” Quincy Larson is very active on Quora and I highly recommend signing up and following him.

To attend one of our Atlanta FreeCodeCamp meetups, join the official Facebook Group here: https://www.facebook.com/groups/free.code.camp.atlanta/ We welcome all coders, whether you are going through the online boot camp or not, and are more beginner-focused.

# Bonfire: Slasher Flick

Use either .splice() or .slice() to get the answer to this coding challenge from FreeCodeCamp.

The Challenge:

Return the remaining elements of an array after chopping off n elements from the head.

The head meaning the beginning of the array, or the zeroth index

My Solution:

```function slasher(arr, howMany) {
// it doesn't always pay to be first
arr = arr.slice(howMany, arr.length);
return arr;
}

slasher([1, 2, 3], 2);```

I used the .slice() method and sliced starting at the howMany value, through the length of the array. This challenge took me about ten minutes! Are they getting easier or am I just getting better? I hope it’s the latter!

# Bonfire: Factorialize a Number

Factorialize a Number – great JavaScript coding challenge from free online full-stack bootcamp FreeCodeCamp. This was a tough one that required a couple hours to figure out. Taking a break from these challenges really makes them harder when you start back up!

Challenge:

Return the factorial of the provided integer.

If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.

Factorials are often represented with the shorthand notation n!

For example: 5! = 1 * 2 * 3 * 4 * 5 = 120

Solution:

```function factorialize(num) {
var total = 1;
for (var i = 0; num > i; i++) {
total = total * (i+1);
}
}

factorialize(5);
```

# Unblock JavaScript in Chrome

If you are on Windows using Google Chrome, you may sometimes keep trying to open your localhost URL only to have Chrome block your JavaScript from loading. To enable JavaScript, right click on your web page to Inspect Element.

1. Click the console tab.
2. Click the gear icon in the upper right and go to settings.
3. Uncheck the “Disable JavaScript” checkbox.

# Bonfire: Reverse a String

Completing the Bonfire: Reverse a String on FreeCodeCamp

## Challenge:

Reverse the provided string.

You may need to turn the string into an array before you can reverse it.

Your result must be a string.

## Solution:

```function reverseString(str) {
var str = str.split("").reverse().join("");
return str;
}

reverseString("hello");```

# Difference between ‘git add . ‘ and ‘git add * ‘

What is the difference between the `git add .` and `git add *`?

`\$git add .`

This adds all new and modified files in the current directory, including hidden folders and files (ones that begin with a ‘ . ‘).

`\$git add -A`

This adds all new, modified, and deleted files in the current directory.

`\$git add *`

Adds all files and directories EXCEPT ones that are hidden (begin with a ‘ . ‘ (dot)). The asterisk is actually a shell command and not part of git.

Here is an image from StackOverflow that also addresses the question:

# Linking Snippets in Codeigniter – PHP

Since I have been attending LAMP Camp, I have been learning PHP and MySQL and using MVC frameworks to build web applications. I’m about to start my 6th week tomorrow, so I’m already halfway through! It’s a free 12-week immersive program in Atlanta, that you can read more about here.

To get your certificate of completion, you have to create a personal portfolio site using what you’ve learned. Since we have to use an MVC framework for our project, I’ve chosen Codeigniter since they have a tutorial that comes with the download. Their tutorial is very easy to follow and they teach you how to also connect to a database.

Today I spent my time on the views and getting the Bootstrap Carousel feature to work. I also learned how to link pages together. If you are using the MVC framework Codeigniter for your PHP web application, you can link page views without touching your controller file.

I saved my ‘snippet’ views in their own folder in ‘views/templates’ and just linked to them where I wanted them to appear. Since I worked on the carousel feature today, I put the carousel code in its own file called carousel.php. Then, I added the following code to my home.php view file where I wanted the carousel to appear:

` <?php \$this->load->view("templates/snippets/carousel.php"); ?>`

This is my controller file that loads the home.php view:

```public function view(\$page = 'home')
{
if ( ! file_exists(APPPATH.'/views/pages/'.\$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}

\$data['title'] = ucfirst(\$page); // Capitalize the first letter

}```

# UNIX Commands in Windows Command Prompt

How to use UNIX commands in Windows 10: