Our goal for this bonfire is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this bonfire:

(['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]

([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]

([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]

([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the bonfire title and read the helpful links if you haven't yet.

Quick question, in the functional programming, I came across this code as a solution:

function(){
var videos = [
{
"id": 65432445,
"title": "The Chamber"
},
{
"id": 675465,
"title": "Fracture"
},
{
"id": 70111470,
"title": "Die Hard"
},
{
"id": 654356453,
"title": "Bad Boys"
}
];
// Expecting this output...// [// {// "65432445": "The Chamber",// "675465": "Fracture",// "70111470": "Die Hard",// "654356453": "Bad Boys"// }// ]return videos.
reduce(function(accumulatedMap, video){
// Object.create() makes a fast copy of the accumulatedMap by// creating a new object and setting the accumulatedMap to be the// new object's prototype.// Initially the new object is empty and has no members of its own,// except a pointer to the object on which it was based. If an// attempt to find a member on the new object fails, the new object// silently attempts to find the member on its prototype. This// process continues recursively, with each object checking its// prototype until the member is found or we reach the first object// we created.// If we set a member value on the new object, it is stored// directly on that object, leaving the prototype unchanged.// Object.create() is perfect for functional programming because it// makes creating a new object with a different member value almost// as cheap as changing the member on the original object!var copyOfAccumulatedMap = Object.create(accumulatedMap);
copyOfAccumulatedMap[video.id] = video.title;
return copyOfAccumulatedMap;
},
// Use an empty map as the initial value instead of the first item in// the list.
{});
}

Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.Check the assertion tests for examples.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.Check the assertion tests for examples.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.links:

Oh, so it's taking video.id as the position in the {} in the array? Like some other earlier examples which had missing number values or number values out of order? And result[] = is another way of writing a sort of push function into {}?

Anyone up for double-checking my Map the Debris code? For some reason all of the calculations are off by a tiny fraction and I'm pulling my hair out trying to figure it out. I'm sure it's something trivial that I'm overlooking. Any help is appreciated! [cross-posted]

Hey I have a question: I'm learning how to create margins... The guide says: Your green-box class should give elements -15px of margin. So I typed out this: Your green-box class should give elements -15px of margin. And it says it's wrong?

@nogo10 you can use "global" (or more correctly, within scope) functions within other functions. And also return functions that will "remember" the context on which they were created. That's the beauty of closures

Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Hi, anyone here can help me with this infinite loop on Bonfire: Chunky Monkey?

function chunk(arr, size) { // create an empty array to where elements will be pushed in var splited = []; // while there is any element on array while (arr) { // if size is bigger or equal to array length if (size >= arr.length) { // push slice part from arr into splited splited.push(arr.slice(0, size)); // remove part from original arr arr.splice(0, size); } }

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'.Lastly, ['Alien', 'line'], should return true because all of the letters in 'line' are present in 'Alien'.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Our goal for this bonfire is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this bonfire:

(['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]

([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]

([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]

([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the bonfire title and read the helpful links if you haven't yet.

@pwdd yes, going until the arr.length > size would be an approach. However, you'll need to realize that at some point you may have an array that's not divisible by size, so you may have some remaining elements left over.

function chunk(arr, size) { // create an empty array to where elements will be pushed in var splited = []; // while there is array and it is bigger than size while (arr && arr.length >= size) { // push part of arr into splited splited.push(arr.slice(0, size)); // delete part of arr arr.splice(0, size); } // if the is remainder on arr smaller then size and bigger than 0; if (arr.length > 0) { splited.push(arr); } // return the created array return splited;}

```function chunk(arr, size) { // create an empty array to where elements will be pushed in var splited = []; // while there is array and it is bigger than size while (arr && arr.length >= size) { // push part of arr into splited splited.push(arr.slice(0, size)); // delete part of arr arr.splice(0, size); } // if the is remainder on arr smaller then size and bigger than 0; if (arr.length > 0) { splited.push(arr); } // return the created array return splited;}

@pwdd This is probably getting ahead of your experience on here (or as a developer), but when you're providing a "service" (e.g., a function), others may not be expecting your service to modify their input variables.

@pwdd Again, this is probably getting ahead of things, but you may want to think of local variables like this, "do I need all this data right now?" In this example, you only need the input array and chunks off it. You don't need the input array x2 at any point.

@davidfaillaiiargs from the line above is an array of all of the arguments passed in, excluding the first one (which is the array to search). .indexOf searches an array for a given value (in this case a) and, if it finds it, returns the index of that item. If it doesn't find it, it returns -1 (because, of course, 0 is a valid answer for an index in an array)

@davidfaillaii So what I've done is kinda turned the problem on it's head. Rather than searching the array for each "destroy" value, I'm instead searching the list of possible "destroy" values for each value in the array. If it's not found (indexof === -1), then it returns true, meaning that it is kept. If it were found (indexof !== -1), then we'd "destroy" it - return false and remove it from the array.

At the start of the function, define a variable to store the number of items in the contacts array. Call it contactsLength.

All of the items in an array are numbered, starting at 0. To cycle through all of the elements of the array, create a for loop that cycles from 0 up to one less than the number of items in the contacts array.

Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.

At the very bottom of the file, call the list function. The list function should then loop through every member of the contacts array and print its information.

having problems with this : 04. The twist comes here: in the body of the loop, rather than printing out every single item in the array, add an if statement that checks to see if the lastName property of the object is equal to the lastName argument. Have the function run printPerson on the person if and only if the lastName property of the person matches the lastName argument.

Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.links:

Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

@ShaklinSyed Don't forget to check if the arguments are number or not because one of the tests checks to see if ([3]) + (2) is undefined because [3] is an object/array and not a number and javaScript will try to convert the [3] to a number and thus returning 5 as expected (but FCC expects that operation to be undefined.

Also, return a function that sums the x of the OUTER function and the first argument of THAT function.

@ShaklinSyed in the IF statement, put the returned ANONYMOUS function inside ELSE. and inside that anonymous function you should return the sum of x and the first argument of the anonymous function. (remember closures)Also have in consideration that you also have to check if the argument in the inner function is a number or not.

@chocobowings right, but I've never seen that, so I'm having a hard time figuring out where to put it so that it's done correctly. I can change the heading to red easy, but the .red-text and where it goes ...???

@Optmistic What you are doing there is applying the procedure you need to the WHOLE string! You need to do that with each word of the string and you can do that two ways... using the String.prototype.split() method or the String.prototype.match() method (which takes a regex or a string as a parameter)

Instructions say to do this: Instead of creating a new style element, try removing the h2 style declaration from your existing style element, then replace it with the class declaration for ".red-text". It sounded to me like they didn't want me to put in an html element

Grab every word inside the string and store it in an array. (using match or split).
To each of the words do this: Replace the first character with its uppercase equivalent and add the rest of the word to it. (you did it right using split, charAt() and toUpperCase there but the .toLowerCase at the end should not be there).
Join the array and return it as a string.

You can do this by using a for-loop or the String.prototype.replace() along with String.prototype.match()

Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.links:

Create a function that looks through an array (first argument) and returns the first element in the array that passes a truth test (second argument).Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

"'if only, if only,' the woodpecker sighs, 'the bark on the tree were as soft as the skies!'. The wolf waits below, hungry and lonely. He cries to the moon! 'If only, if only...'". The book was way better than the movie...

@dting@Azhagan@natac13 Yes, also make sure that you keep in mind that everything should be a set (as in, there can be no duplicates). So remove the duplicates from your inputs and outputs to make things easier.

In this new function, you want to create a new contact object like bob and mary. Instead of having this object's property values be filled with strings though, set them to the appropriate function parameters passed in.

Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Hi Campers! I'm wondering if someone here could explain to me the difference between synchronous and asynchronous? I know MongoDB is synchronous and Node.js is asynchronous but, what does that really mean? I'm lost!

After that, I basically used a do loop nested in a for loop to subtract the largest bill from the change total until the remaining change was less than the current bill or the drawer was out of that bill. The for loop moves through the bills in reverse order, the do loop does the subtraction from the change total as well as the drawer.

@Raincode First of all, just declaring the variable initializes it as "undefined" so leave it as var num;Second, you are breaking the function using break after your test in the IF statement returns true, and it never gets to return your "num"

var james = {
job: "programmer",
married: false
};
// set to the first property name of "james"var aProperty = "job";
// print the value of the first property of "james" // using the variable "aProperty"
console.log(james[aProperty]);

Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Return the provided string with the first letter of each word capitalized.For the purpose of this exercise, you should also capitalize connecting words like 'the' and 'of'.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Return the provided string with the first letter of each word capitalized.For the purpose of this exercise, you should also capitalize connecting words like 'the' and 'of'.Remember to use RSAP if you get stuck. Try to pair program. Write your own code.