14th
Feb 2015
Suzanne Atkinson
Feb 14 2015 09:11 UTC
hey if anyone is up right now (Europe?) having trouble with return largest array bonfire.
seems like this should work. the sumArray subroutine works fine. I'm trying to track which of the 4 arrays is the largest then return that one. Not sureif there is a method I ought to be using tha tI don't know about.
function largestOfFour(arr) {
// You can do this!
var largestArr= [];
var largest = 0;

for (i=0; i<arr.length; i++){
if (sumArray(arr[i])>largest){
largestArr = arr[i];

}

}

function sumArray(subArr) {
var sum = 0;
for (i=0; i<subArr.length; i++){
sum += parseInt(subArr[i], 10);
}
return sum;
}

return largestArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Suzanne Atkinson
Feb 14 2015 09:18 UTC
nevermind, first of all I got it to do what I wanted
but I misunderstood the instructions. From each array return the largest number? not which subarray contains the largest numbers.
@terakilobyte this instructions seem ambiguous "Return an array consisting of the largest numbers in the provided array. The array will contain 4 sub-arrays."
first i summed each subarray but that's clearly not the answer. how many numbers should the truner array consist of ? How many largest numbers? or is it the largest number from each of the 4 subarrays?
Suzanne Atkinson
Feb 14 2015 09:28 UTC
try 2
function largestOfFour(arr) {
// You can do this!
var largestArr= [];

for (i=0; i<arr.length; i++){
temp = largestNum(arr[i]);
largestArr.push(temp);
}

function largestNum(subArr) {
var largest = 0;
for (j=0; j<subArr.length; j++){
if (subArr(j)>largest){
largest=subArr(j);
}

}
return largest;
}

return largestArr ;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Nathan
@terakilobyte
Feb 14 2015 11:35 UTC
@AdventureBear return the single largest element from each sub array
so largestoffour in that last case woudl return 5 27 39 1001
Sudeepto
@Sudeepto
Feb 14 2015 12:00 UTC
@terakilobyte I was just visiting, so instead of returning largestArr , we should do something like .
return Math.max.apply(Math, largestArr);
Nathan
@terakilobyte
Feb 14 2015 12:01 UTC
I’d recommend passing null as the first argument
no sense binding the thisvalue to Math
Sudeepto
@Sudeepto
Feb 14 2015 12:07 UTC
@terakilobyte Okay.
Nathan
@terakilobyte
Feb 14 2015 12:09 UTC
good job on noticing that apply can be used here since we’re passing in arrays, btw
precisely the point of this exercise
Sudeepto
@Sudeepto
Feb 14 2015 12:12 UTC

@terakilobyte Thanks.

Anyways, does anyone here uses Vim ?? I use GVim on Windows 8.1 and Linux Mint . I am new to Vim . So i don't know precisely how to install and uninstall plugins . I followed a tutorial a while back for installing Vundle Package Manager. I think I failed to install it properly . But , at that time I thought it is installed without any problem so I installed YouCompleteMe plugin.

Now I want to remove both these packages . How can I do so ?? Please reply if you want to see my .gvimrc file.

Nathan
@terakilobyte
Feb 14 2015 12:27 UTC
you can remove them by simply removing their lines from your .gvimrc or .vimrc file
then browse the .vim/bundles directory in ~ and remove their containing folders if you don’t want them
Sudeepto
@Sudeepto
Feb 14 2015 13:08 UTC
@terakilobyte Thanks. I was thinking about doing the same thing , but thought it might mess things up :)
Nathan
@terakilobyte
Feb 14 2015 13:10 UTC
the best part is you can alwasy just go to github and find someone’s dotfiles if you do
ycm is a nice bundle btw
why remove it?
I enjoy ycm and tern a lot
Sudeepto
@Sudeepto
Feb 14 2015 13:14 UTC

As I said, I am new to VIM world. So while installing ycm and vundle , there were couple of commands and terms that I didn't understood , so I think the installation was not properly completed.

I wanted auto-completion, syntax-linting for C++ and Python3 . Do you use Gvim as well ??

Nathan
@terakilobyte
Feb 14 2015 13:14 UTC
I use mvim
but they’re all essentially the same
ah for c++ and python3 you’d have to search github
for C related whatnots I use xcode
Sudeepto
@Sudeepto
Feb 14 2015 13:16 UTC
Ohhh. Right now I have a doubt. I am using Gvim in windows and linux. I don't know whether Gvim has full 256 color support on or not. I was using the corporation colorscheme but the background was not showing the same color as the preview showed.
Nathan
@terakilobyte
Feb 14 2015 13:17 UTC
hmm no idea, you could google it most likely
Sudeepto
@Sudeepto
Feb 14 2015 13:17 UTC
which color scheme are you using right now ??
Nathan
@terakilobyte
Feb 14 2015 13:17 UTC
I use solarized
Sudeepto
@Sudeepto
Feb 14 2015 13:17 UTC
Yeah , I use it on Sublime Text.
Nathan
@terakilobyte
Feb 14 2015 13:17 UTC
yeah there’s a solarized plugin for vim too
Sudeepto
@Sudeepto
Feb 14 2015 13:18 UTC
plugin ?? like solarized.vim ??
Nathan
@terakilobyte
Feb 14 2015 13:18 UTC
yep
Sudeepto
@Sudeepto
Feb 14 2015 13:20 UTC
I recently found ByteFluent . It also has some nice themes.
Are you using Macbook Pro ?? You know I always wanted to buy one, but here its quite expensive :(
Nathan
@terakilobyte
Feb 14 2015 13:21 UTC
expensive here as well
yes I’m using a 15” retina macbook pro
It’s now 3 years old, and still going super strong
though quincy uses a macbook air for all his development and loves it
says it’s enough power for him
Sudeepto
@Sudeepto
Feb 14 2015 13:23 UTC
Is it true that if an Apple product is broken or not functioning properly, the Customer Care replace it with a new one ??
Cassandra Cruz
@lambdatastic
Feb 14 2015 13:23 UTC
If you have the nice product care plan, they’ll do it if it’s unfixable
Sudeepto
@Sudeepto
Feb 14 2015 13:24 UTC
What's a product care plan ??
Nathan
@terakilobyte
Feb 14 2015 13:25 UTC
Cassandra Cruz
@lambdatastic
Feb 14 2015 13:25 UTC
Basically insurance you buy when you get the computer. Lets you take it back and get it fixed if any issues come up with it.
Nathan
@terakilobyte
Feb 14 2015 13:26 UTC
airport employee dropped it in korea
Cassandra Cruz
@lambdatastic
Feb 14 2015 13:26 UTC
Ooh, ouch.
Nathan
@terakilobyte
Feb 14 2015 13:26 UTC
I took it to the apple store, they replaced the monitor, case, ram, hard drive, keyboard, and battery
free
Cassandra Cruz
@lambdatastic
Feb 14 2015 13:26 UTC
Sometimes they’re generous, but I haven’t had the chance to see yet.
This only mt first MBP
Nathan
@terakilobyte
Feb 14 2015 13:26 UTC
I’ve always had good luck with them
Sudeepto
@Sudeepto
Feb 14 2015 13:27 UTC
@alicekamada So apart from buying the product , we have to buy an insurance plan to cover any future damages ??
Nathan
@terakilobyte
Feb 14 2015 13:27 UTC
so I’ll probably alwasy buy their products
if it’s apple’s fault, no
and literally anything happens to it that you didn’t flat out do maliciously, apple will cover it
driving down the road and someone tbones you and your comp goes flying? with applecare they’ll just replace it
hell with that story they’d probably replace it anyway and wish you well
Cassandra Cruz
@lambdatastic
Feb 14 2015 13:28 UTC
Probably
I don’t really need it because I have a rider in my renter’s insurance just for personal electronics, but I’ve only heard good things about it.
Nathan
@terakilobyte
Feb 14 2015 13:29 UTC
my mbp is old
Sudeepto
@Sudeepto
Feb 14 2015 13:30 UTC
@terakilobyte But you still use more RAM than me . I have 4GB 1333 Mhz :)
Nathan
@terakilobyte
Feb 14 2015 13:30 UTC
use or have? ;)
I probably rarely use more than 2-3gb of what I have available
Sudeepto
@Sudeepto
Feb 14 2015 13:31 UTC
Sorry . Not a native english speaker. :)
Nathan
@terakilobyte
Feb 14 2015 13:32 UTC
actually I’m using most of my memory looking at the activity monitor
but I think what’s happening is osx is letting apps be memory hogs while it’s available
Cassandra Cruz
@lambdatastic
Feb 14 2015 13:32 UTC
@terakilobyte …how?
Nathan
@terakilobyte
Feb 14 2015 13:33 UTC
Sudeepto
@Sudeepto
Feb 14 2015 13:34 UTC

But recently I have noticed something weird. While using Windows 8.1 Chrome uses ~ 1-1.5 GB of RAM with 6-7 tabs open.

But on Linux mint, it uses even more amount of memory even when only 2-3 tabs are open, like 2-2.4 GB :(

Nathan
@terakilobyte
Feb 14 2015 13:37 UTC
yeah my app memory is sitting around 3gb atm
the memory pressure isn’t bad it looks like
Sudeepto
@Sudeepto
Feb 14 2015 13:37 UTC
Nathan
@terakilobyte
Feb 14 2015 13:38 UTC
indicating maybe half
at 4gb you may want to run a 32 bit system
Sudeepto
@Sudeepto
Feb 14 2015 13:40 UTC
I may go for another 4GB in near future. But does running a 64 bit machine with 4GB RAM not good ??
Nathan
@terakilobyte
Feb 14 2015 13:41 UTC
well remember why 64gb was made, to take advantage of more ram
err 64 bit
it allows access to a lot more memory, but itself takes up more memory
if you expand your ram then stay at 64 bit, I think the total usable ram for a 32 bit system is right around 4gb
Sudeepto
@Sudeepto
Feb 14 2015 13:42 UTC
Yeah I know that. But the reason why machine is not using all of 4 GB is because I don't have a dedicated graphics card.
@terakilobyte You are from USA right ??
Nathan
@terakilobyte
Feb 14 2015 13:50 UTC
I am
Suzanne Atkinson
Feb 14 2015 14:58 UTC
@terakilobyte thanks, that's what I finally guessed. I slept really well last night but was up from 3am - 5am and figured I'd try a bonfire. See what you've created? Lol.
Nathan
@terakilobyte
Feb 14 2015 15:00 UTC
lol
Suzanne Atkinson
Feb 14 2015 15:01 UTC
FWIW that Code I posted worked just fine except for arr(j) needed to be arr[j]
Dominic Jones
@towwiow
Feb 14 2015 15:07 UTC
Suzanne Atkinson
Feb 14 2015 15:07 UTC
morning, @towwiow
Dominic Jones
@towwiow
Feb 14 2015 15:07 UTC
What's FWIW? Lol
Suzanne Atkinson
Feb 14 2015 15:08 UTC
for what it's worth
prob not worth even typing FWIW, FWIW. lol.
sort of like a columnist typing "In my opinion I think..."
a little redundant.
Nathan
@terakilobyte
Feb 14 2015 15:16 UTC
;)
Dominic Jones
@towwiow
Feb 14 2015 15:20 UTC
lol
I don't have anything to say to that... no comment.
Sudeepto
@Sudeepto
Feb 14 2015 15:21 UTC

Hey does anyone know where can I find free fonts to download for windows and linux ?? Preferably in ttf format.

I want to use Inconsolata font. But don't know which site is the best for fonts .

Dominic Jones
@towwiow
Feb 14 2015 15:21 UTC
Sudeepto
@Sudeepto
Feb 14 2015 15:22 UTC
@towwiow Thanks .
Dominic Jones
@towwiow
Feb 14 2015 15:22 UTC
You're welcome. There's a lot on there.
Suzanne Atkinson
Feb 14 2015 15:22 UTC
da man (dot com).
Dominic Jones
@towwiow
Feb 14 2015 15:23 UTC
Didn't return anything for inconsolata though.
Sudeepto
@Sudeepto
Feb 14 2015 15:23 UTC
Yup :(
Suzanne Atkinson
Feb 14 2015 15:23 UTC
what are you using it for @Sudeepto ?
Dominic Jones
@towwiow
Feb 14 2015 15:24 UTC
I think I'm going to pound through those standford challenges more today while at work.
Sudeepto
@Sudeepto
Feb 14 2015 15:24 UTC
@AdventureBear I usually change my editor's font while programming . RIght now I am using Source Code Pro, Meslo and Monaco as my main fonts. :)
Suzanne Atkinson
Feb 14 2015 15:25 UTC
what editor are you using?
@towwiow hurry up so you can get to the good stuff
:)
Dominic Jones
@towwiow
Feb 14 2015 15:25 UTC
:no_mouth: you spotted me!
caught me dragging my feet lol
Sudeepto
@Sudeepto
Feb 14 2015 15:26 UTC
@AdventureBear I use Sublime Text 3 and Gvim . Learning to use Vim right now . Only know basics like movement, yank-paste etc. Which one do you use ??
Nathan
@terakilobyte
Feb 14 2015 15:26 UTC
I’ve converted her to the dark side
soon all will join
Dominic Jones
@towwiow
Feb 14 2015 15:27 UTC
lol we talking about editors right now?
Sudeepto
@Sudeepto
Feb 14 2015 15:27 UTC
@terakilobyte Amen !
Suzanne Atkinson
Feb 14 2015 15:31 UTC
lol. he got me on webstorm right now. Getting used to it. He said it was cool b/c it integrated with version control, but they said to use command line for version control anyway, lol.
maybe some one else saida bout the version control
Nathan
@terakilobyte
Feb 14 2015 15:33 UTC
nah I mentioned vcs
it’s faster to use the command line
Suzanne Atkinson
Feb 14 2015 15:33 UTC
Nathan
@terakilobyte
Feb 14 2015 15:33 UTC
but webstorm does it, and I use it to resolve merge conflicts
I’ll also quickly switch between branches in it
it’s real power comes in the fact it will index all of the internal modules ina project as well as node itself
so you get really really powerful context hinting
Sudeepto
@Sudeepto
Feb 14 2015 15:34 UTC
@terakilobyte From where did you learn to use git ??
Suzanne Atkinson
Feb 14 2015 15:39 UTC
wow, that sounds like a nother pairing session is needed! ha
hey question, with branches in git (or any vcs I guess), should old branches be deleted noce they are merged?
Nathan
@terakilobyte
Feb 14 2015 15:42 UTC
I like to keep them around for posterity
I learned the basics of git just by reading online, searchign when I needed answer, and using it
it’s fairly intuitive
Suzanne Atkinson
Feb 14 2015 15:44 UTC
the ROR course I took from prag programming used it and was very good at the basics.
Somewhere I read or go tthe idea that if everything was up to speed, you should only have a master.
Suzanne Atkinson
Feb 14 2015 16:26 UTC
@terakilobyte doing repeating string bonfire, got this after running the code, it looks like my out put is the expected but it's not passing?
assert.strictEqual(repeat('abc', 3), 'abcabcabc', 'should repeat a string n times');AssertionError:should repeat a string n times: expected 'abc' to equal 'abcabcabc'
wait, nevermind, not yet...
silly error. used =+ instead of =+
i'm learnign a lot with the easy bonfires
Nathan
@terakilobyte
Feb 14 2015 16:40 UTC
:)
Suzanne Atkinson
Feb 14 2015 16:41 UTC
will there be a way to track your bonfires, like the challenges? I've peeked at the sourcecode to see hwo many there are, but it's still a nice feeling to check things off!
Nathan
@terakilobyte
Feb 14 2015 16:43 UTC
yep
we’re already saving all the bonfires
every time you complete one it’s saved
Suzanne Atkinson
Feb 14 2015 16:44 UTC
that's cool. I peeked at some source code to try and get an idea of what's going on in the backend.
Suzanne Atkinson
Feb 14 2015 16:50 UTC
I also noticed my challenge count going up with each one! Yippee
Sudeepto
@Sudeepto
Feb 14 2015 16:58 UTC
Hey can someone help me in challenge 16 . Customizing bootstrap. It seems that codepen.io is not loading the html that we need to customise . Any ideas. ??
Dominic Jones
@towwiow
Feb 14 2015 17:03 UTC
Sudeepto
@Sudeepto
Feb 14 2015 17:09 UTC

@towwiow What animate.css. The instruction asks us to visit bootswatch.com and use any one of the bootstrap theme we like. I have used the SuperHero theme . I have pasted both of them in codepen's html and css panes but still the page is doing nothing.

I tried adding a different web page , a simple p tag with some message , and it loaded it perfectly. Don't know what's the problem :(

@towwiow The css file name is bootstrap.css
Dominic Jones
@towwiow
Feb 14 2015 17:10 UTC
got ya. thinking of a different challenge.
give me a moment
Sudeepto
@Sudeepto
Feb 14 2015 17:15 UTC
@towwiow Its a generic link codepen.io/pen
Dominic Jones
@towwiow
Feb 14 2015 17:16 UTC
do you have an account made? Where you can save it and link me to it directly?
that link just takes me to a blank pen.
Sudeepto
@Sudeepto
Feb 14 2015 17:16 UTC
No , i didn't made an account.
@towwiow I am using JSFiddle now . This is the link . ITs working btw . http://jsfiddle.net/tpaq8Lqt/
Dominic Jones
@towwiow
Feb 14 2015 17:34 UTC
Ok. let me know if you need help with the challenge.
Cristián Berríos
@crisberrios
Feb 14 2015 17:38 UTC
Good morning campers
Suzanne Atkinson
Feb 14 2015 17:38 UTC
mornign
Dominic Jones
@towwiow
Feb 14 2015 17:40 UTC
morning @crisberrios !
Cristián Berríos
@crisberrios
Feb 14 2015 17:43 UTC
hey Suzanne and Dominic
I'm up for some helping if you need anything :)
Suzanne Atkinson
Feb 14 2015 17:56 UTC
super~ I'm doing bonfires
having trouble pushing to a multidimensional array
chunky monkey challenge
Cristián Berríos
@crisberrios
Feb 14 2015 17:57 UTC
Look at this wonderful code from JS: The Good Parts.
Well... some small bits of theory before:
Arrays in JS aren't really "Arrays" as in C or Java
they are just objects with some special methods
so, you can have arr[0] and arr[100000] but no "places" in between
Also, there is no guarantee that using "for item in array" will iterate correctly over each value
Suzanne Atkinson
Feb 14 2015 17:59 UTC
well here is the input array
['a', 'b', 'c', 'd']
Cristián Berríos
@crisberrios
Feb 14 2015 17:59 UTC
it'll also iterate over those
and moreso, if you add properties like arr["bear"] = value
Suzanne Atkinson
Feb 14 2015 17:59 UTC
and the idea is to output it as:
['a', 'b'], ['c', 'd']
I think
i'm using a counter to keep track of location in the original array
a double nested loop (in the above case it would be i=0 to 1, j=0 to 1,
and then trying to "push" the value @ counter position to the correct spot in the new array.
Cristián Berríos
@crisberrios
Feb 14 2015 18:01 UTC
is it only 4 items
or do you have to group them in groups of 2?
Suzanne Atkinson
Feb 14 2015 18:02 UTC
there is an oinput array and then a number
so in this case,
['a', 'b', 'c', 'd'], 2
the instructions are to make "N" groups from the first array
so 2 groups.
but it could be ann array of 6 elements with a number 3
so 3 groups (of 2)
Cristián Berríos
@crisberrios
Feb 14 2015 18:03 UTC
Suzanne Atkinson
Feb 14 2015 18:03 UTC
here's my code so far...right now just outputting differen tthings to see what it's doing
function chunk(arr, size) {
// Break it up.
//How many new groups?
var numGroups = arr.length/size;

//create empty multidimensional array to fill
var multiArray = [];
var counter = 0;
var count = "";
//iterate over each new group

for (i=0; i<numGroups; i++) {
//place correct "size" of elements into each new group
for (j = 0; j<size; j++) {
multiArray.push(arr[counter]);
count += counter + ", ";
counter =+1;
}
}

return count;
}

chunk(['a', 'b', 'c', 'd'], 2);
the .push command wasn't working, so im' outputting count as well as pushing count to a regular arran and I'm getting 0,1,1,1 or a,b,b,b so i'm not even looping correctly
Cristián Berríos
@crisberrios
Feb 14 2015 18:06 UTC
let's see... var numGroups = arr.length/size;
you might want to use Math.floor
Suzanne Atkinson
Feb 14 2015 18:07 UTC
I am assuming they are all integers pre-planned! but that is a good point. I found one problem.
2nd time today
Cristián Berríos
@crisberrios
Feb 14 2015 18:07 UTC
remember, there are no integers in JS
only float numbers, and divisions are ackward
what is the use of counter?
count
i mean
Suzanne Atkinson
Feb 14 2015 18:09 UTC
just trying to figure out how to take the next element in teh original array
and push it into the multidimention.
I was originally using something like i*j+j
Cristián Berríos
@crisberrios
Feb 14 2015 18:10 UTC
well, keep it simple
Suzanne Atkinson
Feb 14 2015 18:10 UTC
which ins't quite right either, but figured just counting as a way of keeping track manually should work
Cristián Berríos
@crisberrios
Feb 14 2015 18:10 UTC
1st... some useful methods for this problem: push/pop and shift/unshift
Suzanne Atkinson
Feb 14 2015 18:10 UTC
I have this working now, but it returns the original array.
function chunk(arr, size) {
// Break it up.
//How many new groups?
var numGroups = arr.length/size;

//create empty multidimensional array to fill
var multiArray = [];
var counter = 0;
var count = "";
//iterate over each new group

for (i=0; i<numGroups; i++) {
//place correct "size" of elements into each new group
for (j = 0; j<size; j++) {
multiArray.push(arr[counter]);
//count += counter + ", ";
counter += 1;
}
}

return multiArray;
}

chunk(['a', 'b', 'c', 'd'], 2);
my problem is the multidimensional part. ??
Cristián Berríos
@crisberrios
Feb 14 2015 18:11 UTC
yes
I think you are missing just 1 little step
Suzanne Atkinson
Feb 14 2015 18:12 UTC
can I have a hint? :)
Cristián Berríos
@crisberrios
Feb 14 2015 18:13 UTC
well, as you see, multiArray is returning the original array
what is the grouping step?
Suzanne Atkinson
Feb 14 2015 18:14 UTC
I can't get the syntax right. So I simplified it to see that it was retriving the values.
the one little step I'm missing is the step that I'm missing, lol.
I've tried this:
multiArray[i][j].push(arr[counter]);
as well as
multiArray[i].push(arr[counter]);
seems like iether should work depending on how the language works. ?
so I figure it's a syntax problem
Cristián Berríos
@crisberrios
Feb 14 2015 18:15 UTC
1st option is 99% good
and, as you say, it's a syntax problem
Suzanne Atkinson
Feb 14 2015 18:16 UTC
OK at least I am not crazy
Cristián Berríos
@crisberrios
Feb 14 2015 18:16 UTC
what you do when pushing is let the push function decide what index to assign to the pushed item
Suzanne Atkinson
Feb 14 2015 18:16 UTC
OK
i guess that makes sense, so it should choose the j? or do I set the size of the dimensions first ?
Cristián Berríos
@crisberrios
Feb 14 2015 18:17 UTC
since you already know where the item should be
you don't need push
Suzanne Atkinson
Feb 14 2015 18:17 UTC
aha!
Cristián Berríos
@crisberrios
Feb 14 2015 18:17 UTC
just to assign it
Suzanne Atkinson
Feb 14 2015 18:17 UTC
OH
wow
Cristián Berríos
@crisberrios
Feb 14 2015 18:18 UTC
multiArray[i][j] = value;
Suzanne Atkinson
Feb 14 2015 18:18 UTC
I get this error when I try that. Thanks though, you made perfect sense! Guess I was eager to be pushy.
multiArray[i][j].push(arr[counter]);
sorry, wait
cannot set property 0 of undefined
for this line:
multiArray[i][j]=arr[counter];
Cristián Berríos
@crisberrios
Feb 14 2015 18:20 UTC
and... that's correct
Suzanne Atkinson
Feb 14 2015 18:20 UTC
lol
Cristián Berríos
@crisberrios
Feb 14 2015 18:20 UTC
since there isn't an array at [i]
so you can insert something at [j]
Suzanne Atkinson
Feb 14 2015 18:21 UTC
iindexing doesn't start at 0? Should this place soemthing at 0,0, then 0, 1, then 1,0, then 1,1? Or am I getting languages mixed up
hmph. The sun went away. it senses my frustration.
Cristián Berríos
@crisberrios
Feb 14 2015 18:22 UTC
well
in JS you can have arr[10] and arr[0] might be undefined
to specify an index of an array you need an array object, even if it's empty.
so how to do an easy fix
Suzanne Atkinson
Feb 14 2015 18:22 UTC
do I need to explitly first define the empty array?
var multiArray = [];
is what I have
Sudeepto
@Sudeepto
Feb 14 2015 18:24 UTC

Hello @crisberrios I am doing FCC challenge no. 16 customizing bootstrap. Here is the link of the fiddle
Customizing_bootstrap

It asked me to make it a one-column page. Can you help me give some pointers how to achieve it ?? I was thinking about the float property.

Suzanne Atkinson
Feb 14 2015 18:25 UTC
Cristián Berríos
@crisberrios
Feb 14 2015 18:25 UTC
@Sudeepto check how many columns are the sections using
Well, you must initialize the array before assigning the values
you can do it at start or make a check before pushing
But well... there are many approaches for solving that problem
Suzanne Atkinson
Feb 14 2015 18:27 UTC
var multiArray = ([[]]);
var multiArray = ([][]);
with and without the () doesn't work either.
Sudeepto
@Sudeepto
Feb 14 2015 18:28 UTC
@crisberrios I think there are two columns in the page right ?? col-md-3 and col-md-9.
Cristián Berríos
@crisberrios
Feb 14 2015 18:29 UTC
yes
@Sudeepto yes
@AdventureBear well, let's not complicate the solution
Sudeepto
@Sudeepto
Feb 14 2015 18:30 UTC
@crisberrios And I need to somehow make co-md-3 column merge with col-md-9 . Correct ??
Julie Myers
@BlueOceanView
Feb 14 2015 18:30 UTC
@AdventureBear What are you trying to do?
Suzanne Atkinson
Feb 14 2015 18:30 UTC
chunky monkey coderbyte
Cristián Berríos
@crisberrios
Feb 14 2015 18:30 UTC
Suzanne Atkinson
Feb 14 2015 18:31 UTC
problem I am having is refactoring into a multidimensional array by assigning a value to a position in the array
i tried something like this
Cristián Berríos
@crisberrios
Feb 14 2015 18:31 UTC
but you have to group the entries first
or initialize the original array
Suzanne Atkinson
Feb 14 2015 18:31 UTC
(not the whole code, just the loop part)
  for (i=0; i<numGroups; i++) {
//place correct "size" of elements into each new group
var multiArray[i]=[];
for (j = 0; j<size; j++) {
multiArray[i].push(arr[counter]);
counter += 1;
}
}
Sudeepto
@Sudeepto
Feb 14 2015 18:32 UTC
Cristián Berríos
@crisberrios
Feb 14 2015 18:32 UTC
for (i = 0; i < numGroups; i ++) {
multiArray[i] = [];
}
Suzanne Atkinson
Feb 14 2015 18:32 UTC
ugh I removed the var in my code above and I'm getting some partial success
Cristián Berríos
@crisberrios
Feb 14 2015 18:34 UTC
it's missing [j]
also a way to initialize [i] before assigning [j]
Sudeepto
@Sudeepto
Feb 14 2015 18:35 UTC

@AdventureBear Hey I have not reached that far yet, but as soon as I load the page, the console shows an error which was occurring due to extra parenthesis around the function call.

DId you noticed that ??

Suzanne Atkinson
Feb 14 2015 18:35 UTC
well in the above case the j is just looping through the number of times to push, so I'm no longer using it in the definition.
Cristián Berríos
@crisberrios
Feb 14 2015 18:36 UTC
well, that's right
Suzanne Atkinson
Feb 14 2015 18:36 UTC
@Sudeepto yes I fixed that already, I think it's a small bug. @terakilobyte FYI
Cristián Berríos
@crisberrios
Feb 14 2015 18:36 UTC
you don't need [j] in that case
Suzanne Atkinson
Feb 14 2015 18:36 UTC
so I think I have my loops backwards.
again misunderstanding the original instructions
Cristián Berríos
@crisberrios
Feb 14 2015 18:37 UTC
do you think?
let me check
Suzanne Atkinson
Feb 14 2015 18:37 UTC
I'm not breaking up into n groups, I'm returning groups of n length
I was understanding the first. But I think the 2nd is what's wanted.
which addresses something you brought up, what to do with the remainder.
so I should be able to fill (n) spots of the first grouped array, then move to the next group, without needing to know how many groups there will be. Until I'm at the end of the first array.
like dealing cards in to a group of n people in a way. Round 1, round 2, oops, not enough for round 3...
I think i need a break!
Cristián Berríos
@crisberrios
Feb 14 2015 18:41 UTC
I see what's the error
check how many groups are you doing for the failed test cases
Suzanne Atkinson
Feb 14 2015 18:42 UTC
Cristián Berríos
@crisberrios
Feb 14 2015 18:42 UTC
I thought it was checking only for whole groups, but you also need to return partial groups
Suzanne Atkinson
Feb 14 2015 18:42 UTC
I run out of things to add in the failed test
right
Cristián Berríos
@crisberrios
Feb 14 2015 18:42 UTC
and I told you to use Math.floor for the number of groups
Suzanne Atkinson
Feb 14 2015 18:42 UTC
I'm going to go grab lunch, I think I need some calories. BRB
Cristián Berríos
@crisberrios
Feb 14 2015 18:42 UTC
but...
Suzanne Atkinson
Feb 14 2015 18:42 UTC
HAHAH
"told you so..."
Cristián Berríos
@crisberrios
Feb 14 2015 18:43 UTC
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
Feb 14 2015 18:43 UTC
@AdventureBear we need to split the array into a multidimensional array containing arrays of size size right ??
Cristián Berríos
@crisberrios
Feb 14 2015 18:45 UTC
@Sudeepto did yo manage to make it 1 column?
Suzanne Atkinson
Feb 14 2015 18:47 UTC
@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
Feb 14 2015 18:47 UTC
@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
Feb 14 2015 18:48 UTC
@Sudeepto nope, it might not be a multiple
Sudeepto
@Sudeepto
Feb 14 2015 18:49 UTC
@AdventureBear Okay that means that the multi-dimensional array's last element ,can have less than size elements. Right ?? :)
Suzanne Atkinson
Feb 14 2015 18:52 UTC
yes
yes, lat element less than size elements
Sudeepto
@Sudeepto
Feb 14 2015 19:40 UTC
Suzanne Atkinson
Feb 14 2015 19:43 UTC
ooh yes pleeeeeze!!!
Sudeepto
@Sudeepto
Feb 14 2015 19:43 UTC
can I give you the solution code ?? Or some hints ??
@AdventureBear Is it okay here to share solutions ??
Suzanne Atkinson
Feb 14 2015 19:45 UTC
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
Feb 14 2015 19:45 UTC
 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
Feb 14 2015 19:46 UTC
whoa, splicing an array???
I never would have looked for that.
Sudeepto
@Sudeepto
Feb 14 2015 19:46 UTC
the splice method dynamically reduces the array and returns the elements as an array itself.
Suzanne Atkinson
Feb 14 2015 19:47 UTC
that must be the key to this challenge!
so once it's splice, push takes care of the rest?
Sudeepto
@Sudeepto
Feb 14 2015 19:47 UTC
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
Feb 14 2015 19:49 UTC
so simple
Sudeepto
@Sudeepto
Feb 14 2015 19:50 UTC
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
Feb 14 2015 19:53 UTC
I’d prefer you share hints
lead the person to self discovery
unless the answer is just right there
Sudeepto
@Sudeepto
Feb 14 2015 19:54 UTC
@AdventureBear Here is the MDN documentation for splice
Splice
Danny Fritz
@dannyfritz
Feb 14 2015 19:55 UTC
Do any of the challenges focus on debugging js?
Cristián Berríos
@crisberrios
Feb 14 2015 19:56 UTC
@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
Feb 14 2015 19:57 UTC
@terakilobyte Yeah. But @AdventureBear was struggling for many hours. That's why I shared the code with her.
Nathan
@terakilobyte
Feb 14 2015 19:57 UTC
@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
Feb 14 2015 19:59 UTC
Okay friends. Good Night . 1:30 AM here. Byee :)
Cristián Berríos
@crisberrios
Feb 14 2015 20:00 UTC
@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
Feb 14 2015 20:06 UTC
@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
Feb 14 2015 20:07 UTC
hehe don't worry, I'm still trying to change mi mindset from C/C# to JS
Sudeepto
@Sudeepto
Feb 14 2015 20:08 UTC
@crisberrios Will think about it though. But for now . Buenas Noches :) Adiós
Cristián Berríos
@crisberrios
Feb 14 2015 20:08 UTC
goodnight!
Nathan
@terakilobyte
Feb 14 2015 20:14 UTC
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….
not sure what else you could ask for in a programming language
maybe pointers
that’d be pretty cool
Danny Fritz
@dannyfritz
Feb 14 2015 20:21 UTC
@terakilobyte when i say debugging. i mean using the dev tools in chrome or other browsers, not console.log. :P
Nathan
@terakilobyte
Feb 14 2015 20:22 UTC
the way bonfire works I’m not sure that’s possible, though it may be
Danny Fritz
@dannyfritz
Feb 14 2015 20:24 UTC
put a debugger; statement in a bonfire and see what happens. ;)
ah, it hits the statement and shows it in the debugger, but the sandbox times out.
Cristián Berríos
@crisberrios
Feb 14 2015 20:26 UTC
better reflection
but with es6 things surely got better
well, back to work. putting together an input form for my assigned project
Nathan
@terakilobyte
Feb 14 2015 20:39 UTC
@dannyfritz yeah the sandbox will be destroyed after 3 seconds
I might be able to write a debug mode for it
but at that point all safety is abandoned
though if you’re using your debugger you probably won’t write an infinite loop