by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 14 22:38
    @bjorno43 banned @minitechtips_twitter
  • May 14 22:37
    @bjorno43 banned @real-action
  • Feb 01 00:26
    @bjorno43 banned @Ndoua
  • Jan 07 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • May 10 2019 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 27 2019 19:46
    @mstellaluna banned @zhonghuacx
  • Apr 25 2019 17:12
    @mstellaluna banned @cmal
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:09
    thecodingaviator commented #31179
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:07
    thecodingaviator commented #31182
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator commented #31190
  • Apr 01 2019 18:05
    thecodingaviator commented #31157
  • Apr 01 2019 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

Suzanne Atkinson
@AdventureBear
HAHAH
"told you so..."
Cristián Berríos
@crisberrios
it should be Math.ceil
since you want the upper number of possible groups
so if the division returns 1.5
you would want to have 2 groups
Sudeepto
@Sudeepto
@AdventureBear we need to split the array into a multidimensional array containing arrays of size size right ??
Cristián Berríos
@crisberrios
@Sudeepto did yo manage to make it 1 column?
Suzanne Atkinson
@AdventureBear
@Sudeepto yes I think that is correct. but there may be leftovers so either a) we don't know/care about how many there will be, just keep adding until we run out. or b) use @crisberrios suggestion for math.ciel to get the max number, knowing that the final one may not be filled
Sudeepto
@Sudeepto
@crisberrios Nope . I am fiddling with the css . :(
@AdventureBear my only doubt was whether it is provided or not whether size will be a multiple of len(arr) as the array element .
Cristián Berríos
@crisberrios
@Sudeepto nope, it might not be a multiple
Sudeepto
@Sudeepto
@AdventureBear Okay that means that the multi-dimensional array's last element ,can have less than size elements. Right ?? :)
Suzanne Atkinson
@AdventureBear
yes
yes, lat element less than size elements
Sudeepto
@Sudeepto
@AdventureBear I solved your problem :) Reply if you want help okay ??
Suzanne Atkinson
@AdventureBear
ooh yes pleeeeeze!!!
Sudeepto
@Sudeepto
can I give you the solution code ?? Or some hints ??
@AdventureBear Is it okay here to share solutions ??
Suzanne Atkinson
@AdventureBear
yes there is no restriction or code of conduct prohibiting. FCC is a self-guided learning resource and pairing is encouraged. that's my understanding
Sudeepto
@Sudeepto
 function chunk(arr, size) {
  // Break it up.
  var myArr = [] ;

  while( true )
  if (arr.length > size) {
    myArr.push(arr.splice(0, size)) ;
  }
  else {
    myArr.push(arr) ;
    break ;
  }
  return myArr ;
}

chunk(['a', 'b', 'c', 'd'], 2);
Suzanne Atkinson
@AdventureBear
whoa, splicing an array???
I never would have looked for that.
Sudeepto
@Sudeepto
the splice method dynamically reduces the array and returns the elements as an array itself.
Suzanne Atkinson
@AdventureBear
that must be the key to this challenge!
so once it's splice, push takes care of the rest?
Sudeepto
@Sudeepto
So ['a', 'b', 'c', 'd'].splice(0, 2 ) returns ['a', 'b']
After that ['a', 'b', 'c', 'd'] reduce down to [ 'c', 'd'] as I spliced it out and returned it
Suzanne Atkinson
@AdventureBear
so simple
Sudeepto
@Sudeepto
The first argument of splice is the index of element in the array that you want to start and the second argument is the index one less of which is desired
So for ['a', 'b', 'c', 'd'].splice(0, 2 ) first index is 0th index and 2nd index is 2 - 1th i.e. 1
@AdventureBear After that , we just simply push the spliced index into our result index
Nathan
@terakilobyte
I’d prefer you share hints
lead the person to self discovery
unless the answer is just right there
Sudeepto
@Sudeepto
@AdventureBear Here is the MDN documentation for splice
Splice
Danny Fritz
@dannyfritz
Do any of the challenges focus on debugging js?
Cristián Berríos
@crisberrios
@AdventureBear your method was good though. Many ways to achieve the same. You could have used map, even reduce, or a recursive function.
Sudeepto
@Sudeepto
@terakilobyte Yeah. But @AdventureBear was struggling for many hours. That's why I shared the code with her.
Nathan
@terakilobyte
@dannyfritz none currently
though it would be awesome if we got a pull request with 15-30 challenges that did… ;) ;)
console.log-ging fully works in the sandbox
Sudeepto
@Sudeepto
Okay friends. Good Night . 1:30 AM here. Byee :)
Cristián Berríos
@crisberrios
@Sudeepto
 function chunk(arr, size) {
  // Break it up.
  var myArr = [] ;

  while( true )
  if (arr.length > size) {
    myArr.push(arr.splice(0, size)) ;
  }
  else {
    myArr.push(arr) ;
    break ;
  }
  return myArr ;
}

var a = [];
a[1000] = 'hey';
chunk(a, 2);
Sudeepto
@Sudeepto
@crisberrios Sorry. I use Python the most . So my mindset is geared towards it a bit. That's why I never thought of this particular condition. Direct initialization from an arbitrary index is valid in JS but invalid in Python :P
Cristián Berríos
@crisberrios
hehe don't worry, I'm still trying to change mi mindset from C/C# to JS
Sudeepto
@Sudeepto
@crisberrios Will think about it though. But for now . Buenas Noches :) Adiós
Cristián Berríos
@crisberrios
goodnight!
Nathan
@terakilobyte
JS is the awesome. Better object model than a class oriented language (imo), functions are first class citizens, closure support… it’s just dreamy
and with es6 and support for tail recursion….