FCC Bonfire Series 141: Pairwise

Here we go again! This time, we are going to be working on Pairwise. This is a tough one for beginners, but do not worry, let’s go slow and get this beast under control and understand […]

FCC Bonfire Series 138: Arguments Optional

Arguments Optional, oh boy, this is the last challenge before we get to the advanced bonfires section. This bonfire will show us some very interesting facts about JavaScript functions.

For this task, we are asked to write a function that accepts either one or two arguments. If two arguments are provided (and both are numbers), we proceed to return the sum; but, if we are only given a single argument, we must return a function. This returned function will accept one number as argument, and will return the sum of it and the originally passed number. Let’s see a few examples:

addTogether(5, 6);      //-> 11
add(11, 53);    //-> 64

var addFive = addTogether(5);
addFive(6);     //-> 11

var addEleven = addTogether(11);
addEleven(53);  //-> 64