30th
Sep 2015
Tim Bell
@MindfulBell
Sep 30 2015 00:00
move on, try a new one, challenge yourself
Aaron Freidus
Sep 30 2015 00:00
@MindfulBell I hate pomodoro, I gave up to do the bonfires
Hugo
@hugoender
Sep 30 2015 00:01
@MindfulBell sounds good…moving on :)
Jason
@Jauble
Sep 30 2015 00:13
Can anyone help me with this? I commented above the part I need help with. Thanks
CamperBot
@camperbot
Sep 30 2015 00:13
if you want to thank someone, put an @ before their name!
Jason
@Jauble
Sep 30 2015 00:14
``````function chunk(arr, size) {
var numArrays = Math.ceil(arr.length/size);
var numPerArray = size;
var array = [];
for (var i = 0; i < numArrays; i++) {
array[i] = [];
}
var k = 0;
for (var i = 0; i < numArrays; i++) {
for (var j = 0; j < numPerArray; j++) {
array[i][j] = arr[k];
k++;
}
}
var tempArray = [];
var numArrays2 = numArrays - 1;
for (var i = 0; i < numPerArray; i++) {
// this is the part I need help with
if (array[numArrays - 1][i] == null) {
array[numArrays - 1][i].splice(i, i + 1);
}
}
return array;
}

chunk([0, 1, 2, 3, 4, 5], 4, "");``````
Sorry, Ignore that one
``````function chunk(arr, size) {
var numArrays = Math.ceil(arr.length/size);
var numPerArray = size;
var array = [];
for (var i = 0; i < numArrays; i++) {
array[i] = [];
}
var k = 0;
for (var i = 0; i < numArrays; i++) {
for (var j = 0; j < numPerArray; j++) {
array[i][j] = arr[k];
k++;
}
}
for (var i = 0; i < numPerArray; i++) {
// this is the part I need help with
if (array[numArrays - 1][i] == null) {
array[numArrays - 1][i].splice(i, i + 1);
}
}
return array;
}

chunk([0, 1, 2, 3, 4, 5], 4, "");``````
Herman Fassett
@HermanFassett
Sep 30 2015 00:16
@Jauble wjat
hmm
Jason
@Jauble
Sep 30 2015 00:19
@HermanFassett It gives me Uncaught TypeError: Cannot read property 'splice' of undefined
Herman Fassett
@HermanFassett
Sep 30 2015 00:20
@Jauble your code could be shorter I think if you use Array.push();
Jason
@Jauble
Sep 30 2015 00:20
I actually tried that as well
And I tried using the filter() method
Herman Fassett
@HermanFassett
Sep 30 2015 00:21
Hmm, well I used push() in my solution
@Jauble Well to begin with, testing if something is null and then trying to perform slice on it doesn't really work
Jason
@Jauble
Sep 30 2015 00:26
I think I figured it out
I had the index of i in the array [numArrays - 1][i] when I just needed the array itself [numArrays - 1]
I was trying to use .splice on an index inside the array
@HermanFassett I'm going to try to get it to work with .push() as well as .filter()
Daniel Drasdo
@danieldrasdo
Sep 30 2015 00:30
Anyone here good with gulp? I need some help with an error I'm getting which is "Task 'autoprefixer' is not in your gulpfile"
Jason
@Jauble
Sep 30 2015 00:32
@danieldrasdo Sorry, don't even know what gulp is. I'm gonna look it up though so I know lol
Herman Fassett
@HermanFassett
Sep 30 2015 00:32
:)
Rory Smith
@alanbuchanan
Sep 30 2015 00:34
anyone know how to get around this when starting basejumps in c9?
Daniel Drasdo
@danieldrasdo
Sep 30 2015 00:35
heh, np @Jauble, check it out, it's pretty cool, levelup tuts on youtube has a good series on it.
Anyone know how to read and troubleshoot gulpfile.js?
Jason
@Jauble
Sep 30 2015 00:47
@danieldrasdo cool I'll check that out
Herman Fassett
@HermanFassett
Sep 30 2015 00:48
@Jauble I can show you my code with push() if you want
Turned out much simpler than what you were trying
And I'd never heard of gulp either
Jason
@Jauble
Sep 30 2015 01:00
@HermanFassett Ya, I'd like to see what you came up with. Thanks
CamperBot
@camperbot
Sep 30 2015 01:00
jauble sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 225 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
Fausto Ramírez L.
@faustor21
Sep 30 2015 01:00
@alanbuchanan basically you have to go back and forward installing.. you have to try it several time
times*
Rory Smith
@alanbuchanan
Sep 30 2015 01:01
@faustor21 trying it locally now, having even more problems!
Herman Fassett
@HermanFassett
Sep 30 2015 01:02
``````function chunk(arr, size) {
var result = [], temp = [];
for (var i = 1, j = 0; i <= size; i++, j++) {
temp.push(arr[j]);
if (j === arr.length - 1 || i === size && j < arr.length) {
result.push(temp);
temp = [];
i = 0;
}
}
return result;
}
chunk(['a', 'b', 'c', 'd'], 2);``````
@Jauble that's what I did
Jason
@Jauble
Sep 30 2015 01:02
@HermanFassett thanks
CamperBot
@camperbot
Sep 30 2015 01:02
jauble sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave hermanfassett points
Daniel Drasdo
@danieldrasdo
Sep 30 2015 01:03
Fausto Ramírez L.
@faustor21
Sep 30 2015 01:03
@alanbuchanan I'm trying to run the this command `bower install & npm install` but c9 keeps killing it.. it reaches limit 512mb .. So I'm thinking myselft to do a vagrant fresh install for this
the Waypoint: Get Set for Basejumps it a headache
Jason
@Jauble
Sep 30 2015 01:04
@HermanFassett is there a name for that type of for loop?
Herman Fassett
@HermanFassett
Sep 30 2015 01:05
Idk, I guess it's pretty much the same as a regular one, just incrementing 2 variables instead of 1
Rory Smith
@alanbuchanan
Sep 30 2015 01:05
@faustor21 check out the main chat, a guy said it was impossible to use angular fullstack on c9 anymore
Fausto Ramírez L.
@faustor21
Sep 30 2015 01:06
@alanbuchanan my fear.. so VM with it
Jason
@Jauble
Sep 30 2015 01:08
@HermanFassett True, just don't recall seeing one like that
Herman Fassett
@HermanFassett
Sep 30 2015 01:09
Originally I declared j outside of the loop and incremented it inside, and only simplified it like that when the code was working
Fausto Ramírez L.
@faustor21
Sep 30 2015 01:09
@alanbuchanan thanks.. they should update Waypoint: Get Set for Basejumps to do with a local VM
CamperBot
@camperbot
Sep 30 2015 01:09
faustor21 sends brownie points to @alanbuchanan :sparkles: :thumbsup: :sparkles:
Jason
@Jauble
Sep 30 2015 01:09
@HermanFassett I see
Rory Smith
@alanbuchanan
Sep 30 2015 01:09
@faustor21 apparently it's being changed on saturday after the stream
kgoode517
@kgoode517
Sep 30 2015 01:10
Hey would anyone be able to help steer me in the right direction for Bonfire Slasher Flick?
CamperBot
@camperbot
Sep 30 2015 01:10
type `bonfire name` to get some info on that bonfire. And check HelpBonfires chatroom
Herman Fassett
@HermanFassett
Sep 30 2015 01:10
@kgoode517 it can be done with one line inside of the function
Fausto Ramírez L.
@faustor21
Sep 30 2015 01:11
@alanbuchanan ok
Herman Fassett
@HermanFassett
Sep 30 2015 01:12
@kgoode517 All you need to use is slice()
kgoode517
@kgoode517
Sep 30 2015 01:12
@HermanFassett I will keep that in mind I think one of my problems is I dont see the difference between splice and slice functions. I have the mdn documentation up.
Herman Fassett
@HermanFassett
Sep 30 2015 01:14
either could be used in this case
kgoode517
@kgoode517
Sep 30 2015 01:17
@HermanFassett fantastic article thank you!
CamperBot
@camperbot
Sep 30 2015 01:17
kgoode517 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 226 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Sep 30 2015 01:17
Yw
Jonathan
Sep 30 2015 01:31
I'm having some trouble with the diff bonfire. It seems like the method I'm using should work, but it isn't.
``````function diff(arr1, arr2) {
var newArr = [];
// Same, same; but different.
for (i = 0; i < arr1.length; i++) {
newArr = arr2.filter(function remove(val) {
return arr1[i] !== val;
})
}
return newArr;``````
MSWindows10
@MSWindows10
Sep 30 2015 01:33
I'm having problems doing this activity. Here it is:
``````// var ourName = "Free Code Camp";

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
// You'll learn about functions soon.

if(typeof(myName) !== "undefined"){(function(v){return v;})(myName);}``````
The activity is: Waypoint: Declare JavaScript Variables
Jonathan Lee Slew
@jlslew
Sep 30 2015 01:34
@jcadle `newArr = arr2.filter(function remove(val) {` should be `newArr = arr2.filter(function (val) {`
DJ
@qualitymanifest
Sep 30 2015 01:35
@MSWindows10 what problems?
have you tried to solve it yet?
Jonathan
Sep 30 2015 01:35
@jslew Thanks, though it's still not doing the job I'd expect it to do.
CamperBot
@camperbot
Sep 30 2015 01:35
jcadle sends brownie points to @jslew :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jslew
Jon Love
@jayvolr
Sep 30 2015 01:37
@MSWindows10 You just need to create a new variable called myName with your name stored in it.
Jonathan Lee Slew
@jlslew
Sep 30 2015 01:38
@jcadle everytime you loop, you are assigning a new array to `newArr`
Hugo
@hugoender
Sep 30 2015 01:38
quick noobie question…how do you tell codepen to display your site full screen without html css or js windows?
Jonathan Lee Slew
@jlslew
Sep 30 2015 01:38
@hugoender in url replace pen with full
Hugo
@hugoender
Sep 30 2015 01:39
@jlslew thank you!
CamperBot
@camperbot
Sep 30 2015 01:39
hugoender sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 246 | @jlslew | http://www.freecodecamp.com/jlslew
Jonathan
Sep 30 2015 01:39
Ah, I see. That explains why my attempt to use concat() didn't work either
I thought there would be some way of iterating over the first array and comparing it to each value of the second
MSWindows10
@MSWindows10
Sep 30 2015 01:41
@jonlove How do I do that? The instructions weren't clear.
Jonathan Lee Slew
@jlslew
Sep 30 2015 01:41
@jcadle try removing the for-loop and see what the result of `newArr` is
Jon Love
@jayvolr
Sep 30 2015 01:42
@MSWindows10 You can see on the first line an example on how to do it.
@MSWindows10 Without the two /'s, those are used so the code gets ignored
Chris
@Shifthawke
Sep 30 2015 01:43
``````function factorialize(num) {
var = myArray[];
for()
array: !120;
array: !3,628,800;

return num;
}

factorialize(5, 10, 20, 1);``````
@Matko95
Jonathan
Sep 30 2015 01:45
well, without the for loop, I can't iterate through the values of arr1
Mateja Trifunovski
@Matko95
Sep 30 2015 01:45
@Shifthawke what is array: !120; supposed to do? :D
Chris
@Shifthawke
Sep 30 2015 01:45
I don't know I put it in and on the left it says 5
Jonathan Lee Slew
@jlslew
Sep 30 2015 01:45
@jcadle checkout `array.indexOf()`
Shifthawke @Shifthawke facepalm death
Mateja Trifunovski
@Matko95
Sep 30 2015 01:46
@Shifthawke so do you know what factorial is?
Chris
@Shifthawke
Sep 30 2015 01:46
Mateja Trifunovski
@Matko95
Sep 30 2015 01:46
:D
Chris
@Shifthawke
Sep 30 2015 01:46
oh wait
!n
non negative number right?
Mateja Trifunovski
@Matko95
Sep 30 2015 01:48
@Shifthawke hmm !n means not n, but we need n!
Jonathan
Sep 30 2015 01:48
@jlslew I tried another method using array.indexOf, but I was similarly unsuccessful. I'll try again though
Chris
@Shifthawke
Sep 30 2015 01:48
T_T
Mateja Trifunovski
@Matko95
Sep 30 2015 01:49
Chris
@Shifthawke
Sep 30 2015 01:50
Oh so the ! only applies to multiplication in this situation?
Jonathan Lee Slew
@jlslew
Sep 30 2015 01:51
``````newArr = arr2.filter(function(val) {
return arr1.indexOf(val);
});``````
Jonathan
Sep 30 2015 01:52
I'm an idiot
Mateja Trifunovski
@Matko95
Sep 30 2015 01:52
@Shifthawke yep
Star Cherrix
@Sparklepaws
Sep 30 2015 01:52
Hey guys I'm having some weird issues with this JS. It will randomly create an infinite loop that locks up the page (at least that's what I think is happening): http://codepen.io/Sparklepaws/pen/avBrKX?editors=001
Can anyone offer some insight?
Jonathan
Sep 30 2015 01:52
I was trying
``````function diff(arr1, arr2) {
var newArr = [];
// Same, same; but different.
newArr = arr2.filter(function(val) {
for (i = 0; i < arr1.length; i++){
if (arr2.indexOf(arr1[i]) < 0){
return true;
}
}
}
return newArr;``````
though won't arr1.indexOf(val) return an index instead of the boolean that arr2.filter is expecting?
Mateja Trifunovski
@Matko95
Sep 30 2015 01:53
@Sparklepaws it works for me, could you point out when it happens?
Chris
@Shifthawke
Sep 30 2015 01:54
@Matko95 So how would you create a loop for this? No answers. I'll take pseudo code. I want to work it out on my own, but need to be lead to water lol
Hugo
@hugoender
Sep 30 2015 01:54
i hate when code works in codepen but not in brackets….
Star Cherrix
@Sparklepaws
Sep 30 2015 01:54
Well you have to keep pressing the button, and eventually the browser will lock up and resource usage will climb with no error message.
Hugo
@hugoender
Sep 30 2015 01:54
-.-
Mateja Trifunovski
@Matko95
Sep 30 2015 01:54
@Shifthawke so if you've read about factorial on the link i sent you, the number goes from num, to 1
@Shifthawke and multiplies itself through every decrementation
@Shifthawke do you get the idea?
Star Cherrix
@Sparklepaws
Sep 30 2015 01:55
@Matko95 Sorry, forgot to call your name. Yeah basically it's random, so just press the button a lot and eventually the whole browser locks up. You'll need to kill it from Task Manager.
It doesn't return errors in my logs, either.
Don Price
@KingHippo
Sep 30 2015 01:56
If I have zipped versions of my html/css files on my web host do I still need the unzipped version on the host still?
Chris
@Shifthawke
Sep 30 2015 01:57
yes.
That much makes sense. @Matko95
Mateja Trifunovski
@Matko95
Sep 30 2015 01:57
@Shifthawke is that irony? :D
@Sparklepaws oh i see.. so it happens on a random number
Chris
@Shifthawke
Sep 30 2015 01:58
lol actually yes now that I think of it lol
Mateja Trifunovski
@Matko95
Sep 30 2015 01:58
@Sparklepaws what does your filterArr do?
Jonathan
Sep 30 2015 01:58
@jlslew Thanks for the help, though the solution is only partially working. They're diffing some arrays of strings, and that's failing.
CamperBot
@camperbot
Sep 30 2015 01:58
jcadle sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 247 | @jlslew | http://www.freecodecamp.com/jlslew
Jonathan Lee Slew
@jlslew
Sep 30 2015 01:58
@Sparklepaws after awhile `filterArr` will be all false, therefore infinite loop
``````    while(filterArr[randomNumber] !== true){
randomNumber = Math.floor((Math.random() * 10) + 1);
}``````
@jcadle it is partial because you are filtering only one of the array, try reversing arr1 and arr2 and see what happen
Star Cherrix
@Sparklepaws
Sep 30 2015 02:00
@jlslew Hmm but it shouldn't get past this
``````if(filterArr.indexOf(true) === -1){
filterArr = [true,true,true,true,true,true,true,true,true,true];
}``````
@Matko95 The filterArr acts as a sort of list holder, it's meant to assure that within 10 clicks the same quote doesn't get passed twice
After they're all false it resets the entire array with the above code I posted
Jonathan
Sep 30 2015 02:03
@jlslew I just did; it breaks a different set of the samples. I think I need to reconsider my method :/
Sep 30 2015 02:03
So I've started on the Zipline: Build a Personal Portfolio Webpage, and I feel like I have no idea what I am doing. Any suggestions?
Jonathan Lee Slew
@jlslew
Sep 30 2015 02:03
@Sparklepaws sorry, it takes longer because the probability of drawing the remaining numbers get smaller and smaller
Chris
@Shifthawke
Sep 30 2015 02:04
How do you format the infinite loop for factorials? @Matko95
Mateja Trifunovski
@Matko95
Sep 30 2015 02:04
@Shifthawke infinite loop?
Chris
@Shifthawke
Sep 30 2015 02:05
I put infinite loop
Shifthawke @Shifthawke facepalm.
Chris
@Shifthawke
Sep 30 2015 02:05
Wouldn't you need a loop for in this?
Jonathan Lee Slew
@jlslew
Sep 30 2015 02:06
@jcadle 1st filter give you unique value in arr1, 2nd filter gives you unique value in arr2, how about concatenating them?
Mateja Trifunovski
@Matko95
Sep 30 2015 02:06
@Shifthawke yes, you do need the loop, you want the basic look of the loop?
Star Cherrix
@Sparklepaws
Sep 30 2015 02:06
Ah, I think I've got it. @jlslew was right, basically when all booleans except ONE are false it creates a small loophole that allows the while loop to run indefinitely without continuing. I think I can fix it.
Chris
@Shifthawke
Sep 30 2015 02:06
yeah
Jordan Murphy
@jordmur
Sep 30 2015 02:07
@RobbWaddington Use the template they provide you as a starting point. Oh, and bootstrap will probably be your best friend. Hope that helps. :)
Jonathan
Sep 30 2015 02:07
@jslew Just tried it, no luck. I'm going back to the drawing board for now, I think. Appreciate the help.
Aaron Freidus
Sep 30 2015 02:07
Wow commenting code is oddly therapeutic. I think this is exactly what I need to continue doing to slow down the ideas bouncing around in my head.
Mateja Trifunovski
@Matko95
Sep 30 2015 02:07
@Shifthawke
``````for(var i=1;i<=num;i++){
}
//or
for(var i=num;i>0;i--){
}``````
Sep 30 2015 02:07
Alright mate, thanks @jordmur
CamperBot
@camperbot
Sep 30 2015 02:07
robbwaddington sends brownie points to @jordmur :sparkles: :thumbsup: :sparkles:
:star: 197 | @jordmur | http://www.freecodecamp.com/jordmur
Chris
@Shifthawke
Sep 30 2015 02:07
I just don't understand how that fits into the factorial though. T_T
Jordan Murphy
@jordmur
Sep 30 2015 02:07
Seriously though, bootstrap will be your best friend.
Chris
@Shifthawke
Sep 30 2015 02:08
I can only see it in use for a range
Sep 30 2015 02:08
I get that using bootstrap is like 90% of what I need, but I'm just trying to figure out how to get it to do what I want. Maybe I should just read what all bootstrap has to offer.
Star Cherrix
@Sparklepaws
Sep 30 2015 02:09
Thanks @jlslew and @Matko95 !
CamperBot
@camperbot
Sep 30 2015 02:09
sparklepaws sends brownie points to @jlslew and @matko95 :sparkles: :thumbsup: :sparkles:
:star: 402 | @matko95 | http://www.freecodecamp.com/matko95
:star: 248 | @jlslew | http://www.freecodecamp.com/jlslew
Mateja Trifunovski
@Matko95
Sep 30 2015 02:09
@Shifthawke could you tell me what values will "i" have through every iteration
Chris
@Shifthawke
Sep 30 2015 02:09
number values. I mean they vary for each of them
Mateja Trifunovski
@Matko95
Sep 30 2015 02:10
@Shifthawke well, let's say for num=5 what would they be
Chris
@Shifthawke
Sep 30 2015 02:10
5? I'm so stupid.
Jordan Murphy
@jordmur
Sep 30 2015 02:10
Yeah, there's a lot of stuff on the bootstrap site. I think I read through most of those docs. I was a bit at a loss when I started the ziplines.
Chris
@Shifthawke
Sep 30 2015 02:10
I think I'm going to wallow in a corner.
Mateja Trifunovski
@Matko95
Sep 30 2015 02:11
@Shifthawke they would be 1,2,3,4,5 or 5,4,3,2,1
Chris
@Shifthawke
Sep 30 2015 02:11
Oh so the whole range then?
Mateja Trifunovski
@Matko95
Sep 30 2015 02:11
yep
Chris
@Shifthawke
Sep 30 2015 02:11
For 10 that's alot of numbers lol.
Mateja Trifunovski
@Matko95
Sep 30 2015 02:12
well 10!=3628800 :D so yeah..
Jonathan
Sep 30 2015 02:13
@jlslew I just got it working. FWIW, I did this:
``````function diff(arr1, arr2) {
var newArr = [];
// Same, same; but different.
for (i = 0; i < arr1.length; i++){
if (arr2.indexOf(arr1[i]) < 0){
newArr.push(arr1[i]);
}
}
for (i = 0; i < arr2.length; i++){
if (arr1.indexOf(arr2[i]) < 0){
newArr.push(arr2[i]);
}
}
return newArr;
}``````
Jonathan Lee Slew
@jlslew
Sep 30 2015 02:14
Chris
@Shifthawke
Sep 30 2015 02:15
@Matko95 Would you have to create four separate loops or just one?
Mateja Trifunovski
@Matko95
Sep 30 2015 02:15
@Shifthawke only 1, why would you need 4?
Chris
@Shifthawke
Sep 30 2015 02:16
Cause I .... I'm just not getting it.
I have to see examples of likeness with actual numbers put in
I appreciate you trying.
Mateja Trifunovski
@Matko95
Sep 30 2015 02:16
@Shifthawke if you make a loop, and get 1,2,3,4,5 for it to be a factorial it only needs to become `1*2*3*4*5`
Chris
@Shifthawke
Sep 30 2015 02:17
I'm just going to stew for a bit. Question my major choice. I just don't get it.
Herman Fassett
@HermanFassett
Sep 30 2015 02:17
:/
Chris
@Shifthawke
Sep 30 2015 02:18
I just don't understand how you would write a loop for this.
I wrote loops in C++ but for different things.
Mateja Trifunovski
@Matko95
Sep 30 2015 02:20
@Shifthawke
``````for(var i=num;i>0;i--){
fact*=i;
}``````
does that help?
Chris
@Shifthawke
Sep 30 2015 02:21
like greek.
I'm going to see if I can find some examples of whole code on stack overflow.
I'm a freak. If I can see a whole example completed, I can match off that.
Herman Fassett
@HermanFassett
Sep 30 2015 02:24
:P
Mateja Trifunovski
@Matko95
Sep 30 2015 02:26
@Shifthawke the thing i posted actually is a semi-full solution :D it only doesn't work for 0
Ben Botti
@vaquav
Sep 30 2015 02:43
@Matko95 awesome thanks --- http://codepen.io/vaquav/pen/pjNPzP
CamperBot
@camperbot
Sep 30 2015 02:43
vaquav sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 403 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 30 2015 02:43
@vaquav ?
Ben Botti
@vaquav
Sep 30 2015 02:43
@Matko95 I'm wondering why my "background-repeat: no-repeat" element is being overwritten
@Matko95 I'm setting different backgroundImage urls via document.body.style.backgroundImage but it appears that it is overwriting the css I have from my .body class
Jonathan Lee Slew
@jlslew
Sep 30 2015 02:47
@vaquav because body is a tag and not a class
Mateja Trifunovski
@Matko95
Sep 30 2015 02:47
@vaquav yes, you wrote .body{}
Ben Botti
@vaquav
Sep 30 2015 02:48
@jlslew @Matko95 was staring me in the face the whole time :-). I removed the "." and looks good. Thanks guys!
CamperBot
@camperbot
Sep 30 2015 02:48
vaquav sends brownie points to @jlslew and @matko95 :sparkles: :thumbsup: :sparkles:
:warning: vaquav already gave matko95 points
:star: 249 | @jlslew | http://www.freecodecamp.com/jlslew
Chris
@Shifthawke
Sep 30 2015 02:51
@Matko95 ......
Mateja Trifunovski
@Matko95
Sep 30 2015 02:51
@Shifthawke sup? :)
Chris
@Shifthawke
Sep 30 2015 02:51
<3
I went to stack overflow.
didnt get my answer but I feel better
Herman Fassett
@HermanFassett
Sep 30 2015 02:51
:)
Chris
@Shifthawke
Sep 30 2015 02:52
Do you put the numbers outside the loop?
Mateja Trifunovski
@Matko95
Sep 30 2015 02:52
@Shifthawke So you still don't understand it? :D
Chris
@Shifthawke
Sep 30 2015 02:52
I do but don't.
I stole. Cause I'm a thief.
Now I'm trying to get it to apply to mine.
Mateja Trifunovski
@Matko95
Sep 30 2015 02:52
@Shifthawke could you post the solution ? :D
Herman Fassett
@HermanFassett
Sep 30 2015 02:53
x)
Chris
@Shifthawke
Sep 30 2015 02:53
This is as far as I got.
lol
Without a drink
``````function factorialize(num) {

var myNum=1;
for(i=1; i<=num; i++){
myNum= myNum*i;
}

return num;
}

factorialize(5, 10, 20, 0);``````
Making it work now....
And not making the crack in my monitor worse.
Mateja Trifunovski
@Matko95
Sep 30 2015 02:55
@Shifthawke well that's bascially it, you just need to return myNum now
Chris
@Shifthawke
Sep 30 2015 02:55
but there's four numbers...
Mateja Trifunovski
@Matko95
Sep 30 2015 02:55
@Shifthawke don't you worry about that
Chris
@Shifthawke
Sep 30 2015 02:56
but then how do I make it work?
Mateja Trifunovski
@Matko95
Sep 30 2015 02:57
@Shifthawke and please not that 0! is equal to 1, so you need to add a special case
@Shifthawke write return myNum; and test it
Chris
@Shifthawke
Sep 30 2015 02:57
-pushes enter repeatedly-
ok
@Matko95 ....
Herman Fassett
@HermanFassett
Sep 30 2015 02:57
@Matko95 no special case should be needed
Chris
@Shifthawke
Sep 30 2015 02:57
I could kiss you right now
Mateja Trifunovski
@Matko95
Sep 30 2015 02:57
@HermanFassett oh yeah, since myNum is instantly 1
Chris
@Shifthawke
Sep 30 2015 02:58
Pizza for you @Matko95
Mateja Trifunovski
@Matko95
Sep 30 2015 02:58
@Shifthawke It's ok :)
Chris
@Shifthawke
Sep 30 2015 02:58
givepizza @Matko95
Mateja Trifunovski
@Matko95
Sep 30 2015 02:58
@Shifthawke do you atleast understand it?
Chris
@Shifthawke
Sep 30 2015 02:58
purdy!
Mateja Trifunovski
@Matko95
Sep 30 2015 02:58
pbot status
Chris
@Shifthawke
Sep 30 2015 02:58
thanks @Matko95
Mateja Trifunovski
@Matko95
Sep 30 2015 02:58
CamperBot
@camperbot
Sep 30 2015 02:58
shifthawke sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 404 | @matko95 | http://www.freecodecamp.com/matko95
Chris
@Shifthawke
Sep 30 2015 02:58
I do now that I can see it.
Herman Fassett
@HermanFassett
Sep 30 2015 02:58
x)
Chris
@Shifthawke
Sep 30 2015 02:58
See I thought we had to write out all of it
Herman Fassett
@HermanFassett
Sep 30 2015 02:59
But then `myNum *= i;` is so much prettier
Chris
@Shifthawke
Sep 30 2015 02:59
And that's where I was getting stuck. I didn't understand how I would fit all those numbers into a loop like that
I was like are we supposed to put more than one loop or something?
Mateja Trifunovski
@Matko95
Sep 30 2015 03:00
@Shifthawke there is also this solution, if you wanna look at other option :D
``````function factorialize(num) {
if(num==0)
{
return 1;
}
return num*factorialize(num-1);
}``````
Herman Fassett
@HermanFassett
Sep 30 2015 03:00
Oooh recursion fancy
Chris
@Shifthawke
Sep 30 2015 03:01
yay for more solutions!
That seems.... so much easier
-saves-
Herman Fassett
@HermanFassett
Sep 30 2015 03:02
Or
``````function factorialize(num) {
num == 0 ? num = 1 : num = num*factorialize(num-1);
return num;
}``````
x)
Chris
@Shifthawke
Sep 30 2015 03:03
Why are there so many ways to write it?
Herman Fassett
@HermanFassett
Sep 30 2015 03:03
To confuse beginners
Chris
@Shifthawke
Sep 30 2015 03:04
of course lol
I'm going to try the next bonfire. I will be back in the corner sulking in about thirty seconds.
Herman Fassett
@HermanFassett
Sep 30 2015 03:07
:P
Palindrome was harder
Chris
@Shifthawke
Sep 30 2015 03:13
wiki palindrome
CamperBot
@camperbot
Sep 30 2015 03:13

# Explanation:

You have to check if the string you get as an input is a palindrome and return `true` if it is, and `false` otherwise.

Chris
@Shifthawke
Sep 30 2015 03:13
love that confidence lol @HermanFassett
Herman Fassett
@HermanFassett
Sep 30 2015 03:14
xD
Personally
But I always try to make the shortest code possible
I ended up using regex stuff
Chris
@Shifthawke
Sep 30 2015 03:15
I love how it says good luck
Herman Fassett
@HermanFassett
Sep 30 2015 03:15
Hehe ikr
Jon Love
@jayvolr
Sep 30 2015 03:15
Chris
@Shifthawke
Sep 30 2015 03:16
I know It's like here's a spoon, dig that trench
Herman Fassett
@HermanFassett
Sep 30 2015 03:18
:P
Chris
@Shifthawke
Sep 30 2015 03:20
quick question
We have to add racecar and etc.
``palindrome("eye");``
Jordan Bourne
@JordanBourne
Sep 30 2015 03:20
I'm trying to make a countdown timer, and it's sort of working with an setInterval timer, but through each subsequent run it is calling on the setInterval timer an additional time (so output on run 1 is 10, 9, 8, 7... run 2 is 10 10, 9 9, 8 8, 7 7, etc. Anyone have any ideas as why?
Chris
@Shifthawke
Sep 30 2015 03:20
So we would add that there right?
in the " " with eye or in it's own " "
separated with a comma right in with eye
Herman Fassett
@HermanFassett
Sep 30 2015 03:21
@JordanBourne code to show?
Mateja Trifunovski
@Matko95
Sep 30 2015 03:21
@Shifthawke tests do it themselves, just leave that be
Jordan Bourne
@JordanBourne
Sep 30 2015 03:21
``````var timerLength = .05;
var start = new Date().getTime();
var stop = new Date().getTime() + timerLength * 60000;

var myVar = setInterval(function(){myTimer()}, 250);

function myTimer(){
if(start < stop) {
var left = Math.ceil((stop - start) / 1000);
var minLeft = Math.floor(left / 60);
var secLeft = left % 60;
if(secLeft < 10) {
secleft = "0" + secLeft;
}
start = new Date().getTime();
console.log(minLeft + ":" + secLeft);
}
if(stop <= start) {
clearInterval(myVar);
}
}``````
Herman Fassett
@HermanFassett
Sep 30 2015 03:22
@Shifthawke yeah just get some code workin' :P
Chris
@Shifthawke
Sep 30 2015 03:22
oh so it'll automatically check for that. Okies.
Jordan Bourne
@JordanBourne
Sep 30 2015 03:22
I just added that last part with the clearInterval but it doesn't seem to do anything
Chris
@Shifthawke
Sep 30 2015 03:22
Alright.
Shifthawke @Shifthawke cracks knuckles, rolls neck, sets laptop into place, reaches for brownie.
Austin Lin
@austinylin
Sep 30 2015 03:23
``````var chai = require('chai');
var expect = chai.expect;
var assert = chai.assert;

function drawer(price, cash, cid) {
console.log("--------------------------------");
var diff = cash - price;

// You didn't pay enough.
if(diff < 0) { return false; }

// No Cash
if(cid === undefined) { return "Insufficient Funds";}

// Map the denomination to it's unit monetary value.
const valueMap = {
'PENNY': 0.01,
'NICKEL': 0.05,
'DIME': 0.10,
'QUARTER': 0.25,
'ONE': 1,
'FIVE': 5,
'TEN': 10,
'TWENTY': 20,
'ONE HUNDRED': 100
};

// The cashDrawer holds the number of units of each denomination we have.
const cashDrawer = {
'PENNY': 0,
'NICKEL': 0,
'DIME': 0,
'QUARTER': 0,
'ONE': 0,
'FIVE': 0,
'TEN': 0,
'TWENTY': 0,
'ONE HUNDRED': 0,
};

// Fill our cash drawer with the correct number of each denomination.
for(var i = 0; i < cid.length; i++) {
cashDrawer[cid[i][0]] = Math.round(cid[i][1] / valueMap[cid[i][0]]);
}

// Change holds the number of units of each denomination we owe the customer.
const change = {
'PENNY': 0,
'NICKEL': 0,
'DIME': 0,
'QUARTER': 0,
'ONE': 0,
'FIVE': 0,
'TEN': 0,
'TWENTY': 0,
'ONE HUNDRED': 0,
};

// Order to attempt to use bill/coins
var precedence = ['ONE HUNDRED', 'TWENTY', 'TEN', 'FIVE', 'ONE', 'QUARTER',
'DIME', 'NICKEL', 'PENNY'];
// Define variables we will use in the next two loops. (#ES6)
var denomination;
var numAvalibale;
var value;

// Now iterate through the denominations from high to low and use as many
// units of each currency as possible (up to the number we have) until the
// diff (change due) is 0 or we run out of denominations in which case return
// "Insufficient Funds".

for(var j = 0; j < precedence.length; j++) {
if(diff === 0) { break; }
denomination = precedence[j];
numAvalibale = cashDrawer[denomination];
value = valueMap[denomination];
console.log(denomination);
while(numAvalibale > 0 && diff - value >= 0) {
oldDiff = diff;
// Ugly workaround due to the lack of a decimal type.
diff = parseFloat((diff - value).toPrecision(4));

cashDrawer[denomination]--;
change[denomination]++;
numAvalibale = cashDrawer[denomination];
console.log(oldDiff, "(" + denomination +" - "  +numAvalibale + ")", diff);
}
}

if(diff > 0) {console.log("Insufficient Funds"); return "Insufficient Funds";}
if(Object.keys(cashDrawer).map(key => cashDrawer[key]).every(e => e === 0)) {console.log("Closed"); return "Closed";}
console.log(change);

// Convert internal representation (change) into expected format.
var retArr = [];
for(var k = 0; k < precedence.length; k++) {
denomination = precedence[k];
numAvalibale = change[denomination];
value = valueMap[denomination];

if(numAvalibale !== 0) {
retArr.push([denomination, numAvalibale * value]);
}
}
console.log(retArr);
console.log("--------------------------------");
return retArr;
}

drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10],
['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00],
['TEN', 20.00], ['TWENTY', 60.00],
['ONE HUNDRED', 100.00]]);
drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);
drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]);
drawer(19.50, 20.00, [['PENNY', 0.50], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]);
drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);
drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.0``````
I am having trouble with the above code. It runs all of the tests fine when I run it locally (via node) but fails on FCC
Herman Fassett
@HermanFassett
Sep 30 2015 03:24
That's like my next bonfire lol
Austin Lin
@austinylin
Sep 30 2015 03:24
:)
I don’t know that my solutions is anywhere near elegant, but I’m super frustrated by the fact that it runs fine in node and blows up in FCC
Herman Fassett
@HermanFassett
Sep 30 2015 03:26
Hmm that is a bit longer than I expected writing lol
I always just write it in fcc
Chris
@Shifthawke
Sep 30 2015 03:27
Now if only I could spell...
Herman Fassett
@HermanFassett
Sep 30 2015 03:27
I'm still working on my twitchtv zipline :/
Jordan Bourne
@JordanBourne
Sep 30 2015 03:28
That's next for me whenever I figure out this timer thing
Herman Fassett
@HermanFassett
Sep 30 2015 03:28
Then I'll try to finish the Advanced Alogorithm scriptings. Can't wait to get those done with
Austin Lin
@austinylin
Sep 30 2015 03:29
Ugh, the code even works in chrome web inspector, just not FCC. I think i’ll open up a bug.
Herman Fassett
@HermanFassett
Sep 30 2015 03:29
Oh right @JordanBourne your timer thing
Jonathan Lee Slew
@jlslew
Sep 30 2015 03:30
@austinylin it works in node because node can require chai whereas fcc cannot
Austin Lin
@austinylin
Sep 30 2015 03:31
@jlslew here is the code I am running in FCC: ```
``````function drawer(price, cash, cid) {
console.log("--------------------------------");
var diff = cash - price;

// You didn't pay enough.
if(diff < 0) { return false; }

// No Cash
if(cid === undefined) { return "Insufficient Funds";}

// Map the denomination to it's unit monetary value.
var valueMap = {
'PENNY': 0.01,
'NICKEL': 0.05,
'DIME': 0.10,
'QUARTER': 0.25,
'ONE': 1,
'FIVE': 5,
'TEN': 10,
'TWENTY': 20,
'ONE HUNDRED': 100
};

// The cashDrawer holds the number of units of each denomination we have.
var cashDrawer = {
'PENNY': 0,
'NICKEL': 0,
'DIME': 0,
'QUARTER': 0,
'ONE': 0,
'FIVE': 0,
'TEN': 0,
'TWENTY': 0,
'ONE HUNDRED': 0,
};

// Fill our cash drawer with the correct number of each denomination.
for(var i = 0; i < cid.length; i++) {
cashDrawer[cid[i][0]] = Math.round(cid[i][1] / valueMap[cid[i][0]]);
}

// Change holds the number of units of each denomination we owe the customer.
var change = {
'PENNY': 0,
'NICKEL': 0,
'DIME': 0,
'QUARTER': 0,
'ONE': 0,
'FIVE': 0,
'TEN': 0,
'TWENTY': 0,
'ONE HUNDRED': 0,
};

// Order to attempt to use bill/coins
var precedence = ['ONE HUNDRED', 'TWENTY', 'TEN', 'FIVE', 'ONE', 'QUARTER',
'DIME', 'NICKEL', 'PENNY'];
// Define variables we will use in the next two loops. (#ES6)
var denomination;
var numAvalibale;
var value;

// Now iterate through the denominations from high to low and use as many
// units of each currency as possible (up to the number we have) until the
// diff (change due) is 0 or we run out of denominations in which case return
// "Insufficient Funds".

for(var j = 0; j < precedence.length; j++) {
if(diff === 0) { break; }
denomination = precedence[j];
numAvalibale = cashDrawer[denomination];
value = valueMap[denomination];
console.log(denomination);
while(numAvalibale > 0 && diff - value >= 0) {
oldDiff = diff;
// Ugly workaround due to the lack of a decimal type.
diff = parseFloat((diff - value).toPrecision(4));

cashDrawer[denomination]--;
change[denomination]++;
numAvalibale = cashDrawer[denomination];
console.log(oldDiff, "(" + denomination +" - "  +numAvalibale + ")", diff);
}
}

if(diff > 0) {console.log("Insufficient Funds"); return "Insufficient Funds";}
if(Object.keys(cashDrawer).map(key => cashDrawer[key]).every(e => e === 0)) {console.log("Closed"); return "Closed";}
console.log(change);

// Convert internal representation (change) into expected format.
var retArr = [];
for(var k = 0; k < precedence.length; k++) {
denomination = precedence[k];
numAvalibale = change[denomination];
value = valueMap[denomination];

if(numAvalibale !== 0) {
retArr.push([denomination, numAvalibale * value]);
}
}
console.log(retArr);
console.log("--------------------------------");
return retArr;
}

drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10],
['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00],
['TEN', 20.00], ['TWENTY', 60.00],
['ONE HUNDRED', 100.00]]);
drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);
drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]);
drawer(19.50, 20.00, [['PENNY', 0.50], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]);
drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);
drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00],``````
Chris
@Shifthawke
Sep 30 2015 03:37
@austinylin please tell me this isn't a bonfire
Austin Lin
@austinylin
Sep 30 2015 03:38

@jlslew, @HermanFassett figured it out, the issue was a I was doing this:

``  if(diff > 0) {console.log("Insufficient Funds"); return "Insufficient Funds";}``

and should have been doing this:

``````  if(diff > 0) {
console.log("Insufficient Funds");
return "Insufficient Funds";
}``````

which aparently FCC cares about but node doesn’t….

Herman Fassett
@HermanFassett
Sep 30 2015 03:38
@Shifthawke it's one of the last ones
Chris
@Shifthawke
Sep 30 2015 03:38
ermagerd
Herman Fassett
@HermanFassett
Sep 30 2015 03:38
Lol @austinylin
Austin Lin
@austinylin
Sep 30 2015 03:38
@Shifthawke Ya, but there is probably a shorter solution than mine…..
Herman Fassett
@HermanFassett
Sep 30 2015 03:39
@Shifthawke I'm hoping to have a shorter solution. That's my next one
xD
Chris
@Shifthawke
Sep 30 2015 03:39
I hope one day to be able to just write things like this and not feel like I'm hitting a brick wall every time.
Maybe JS isn't my thing.
Herman Fassett
@HermanFassett
Sep 30 2015 03:39
@austinylin there's like no difference in those
Austin Lin
@austinylin
Sep 30 2015 03:39
@HermanFassett RIGHT!
Herman Fassett
@HermanFassett
Sep 30 2015 03:39
@Shifthawke you can do it!
Chris
@Shifthawke
Sep 30 2015 03:40
I hope so. Thanks @HermanFassett I took to c++ well. I was hoping I'd take to this well.
CamperBot
@camperbot
Sep 30 2015 03:40
shifthawke sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 228 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Sep 30 2015 03:40
I get the js, I'm just trying to get used to design with bootstrap and the like
Chris
@Shifthawke
Sep 30 2015 03:40
I think I'm just tryinf to move through everything without really taking the time to actually learn and study the elements.
Herman Fassett
@HermanFassett
Sep 30 2015 03:41
I love js in that you just use `var`
:P
Multi type arrays!!! Woohoo!!
And no fixed length for them either
Well as I'm trying to get good at design, what do you think of this I'm working on:
Jonathan Lee Slew
@jlslew
Sep 30 2015 03:45
@HermanFassett just wondering why shrink the body to 350px?
Herman Fassett
@HermanFassett
Sep 30 2015 03:45
I used Foundation instead of bootstrap just 'cause
Oh I forgot to remove my 20%
350 just the min
rerun shows it fill screen
Jonathan Lee Slew
@jlslew
Sep 30 2015 03:49
@HermanFassett it looks weird on big screen, would suggest using .small and .large classes
Herman Fassett
@HermanFassett
Sep 30 2015 03:49
Augh hate ui
thefacilitator
@thefacilitator
Sep 30 2015 04:30
Hi, I don't understand what to do on the Bonfire: Reverse a String lesson.

The code is as follows, but I'm not sure what bit I'm splitting and reversing:

```function reverseString(str) {
return str;
}

reverseString("hello", "");```

Hanni Abu
@HanniAbu
Sep 30 2015 04:31
@thefacilitator You want to take the string and put the characters in the reverse order
thefacilitator
@thefacilitator
Sep 30 2015 04:32
@HanniAbu I'm not sure what part I'm supposed to add the .split() code to
Hanni Abu
@HanniAbu
Sep 30 2015 04:32
okay, allow me to expand a bit now that i know your real question
So when you call the reverseString function, you pass "hello" as the first parameter
that parameter, "hello", is a string
to use the .split() method, you want to aplly that to a string. in this case it is "hello", the first parameter
so your question is how to do that
Herman Fassett
@HermanFassett
Sep 30 2015 04:35
@thefacilitator use split() to convert a string to an array, use .reverse() to reverse the array then .join() to make a string again
Hanni Abu
@HanniAbu
Sep 30 2015 04:35
when "hello" is passed as the first parameter, it is given the variable name str
so you can use it as soo
str.split()
Herman Fassett
@HermanFassett
Sep 30 2015 04:36
You can't just use split() though, you need an argument inside of it :P
Hanni Abu
@HanniAbu
Sep 30 2015 04:37
@HermanFassett very true
inside .split() you must declare where you want to split the string
Herman Fassett
@HermanFassett
Sep 30 2015 04:37
Just to let you know, it's possible to do all on one line
Chris
@Shifthawke
Sep 30 2015 04:37
I wanna see this one line
post it in the casual room
So I can save it for my second go around lol
Hanni Abu
@HanniAbu
Sep 30 2015 04:39
so splitting "hello" into ['h','e','l','l','o'], would be str.split('')
Herman Fassett
@HermanFassett
Sep 30 2015 04:39
:)
Hanni Abu
@HanniAbu
Sep 30 2015 04:39
the '' withing .split('') dictates to split at every character
@Shifthawke var str = str.split('').reverse().join('')
thefacilitator
@thefacilitator
Sep 30 2015 04:40
So I'm adding .split(" ") to this line: function reverseString(str)
Or am I making a new line of code at the bottom?
Hanni Abu
@HanniAbu
Sep 30 2015 04:40
@thefacilitator It would go within the function
Chris
@Shifthawke
Sep 30 2015 04:40
saving that one too @HanniAbu
Hanni Abu
@HanniAbu
Sep 30 2015 04:41
function reverseString(str) {
str.split("");
}
return str;
sorry, the return is within the function >.<
thefacilitator
@thefacilitator
Sep 30 2015 04:41
Oh, I see. It's worked now, although I'm struggling to work out what term applies to what (i.e. 'string', 'array', etc.) - thanks for that
erika
@erikasf
Sep 30 2015 04:41
Hi there ,i am doing the algorithm challenges and on JSFiddle my solution works for everything. This is for the repeat a line . here is my code and JS Fiddle has the right outcome but the challenge says no?
CamperBot
@camperbot
Sep 30 2015 04:41
if you want to thank someone, put an @ before their name!
erika
@erikasf
Sep 30 2015 04:41

var string = "hi how are you";
string.repeat(2);
console.log(string);

repeat("abc", 3, "");

Hanni Abu
@HanniAbu
Sep 30 2015 04:41
function reverseString(str) {
str.split("");
return str;
}
erika
@erikasf
Sep 30 2015 04:41
oh duh hang on
kind of help if the string wasn't called soemthing else
Hans van Riet
@hansinla
Sep 30 2015 04:57
@erikasf you need to write a function called repeat. You didn’t do that, so your code won’t pass.
``````var repeat = function(str, num) {
// return the repeated string
};``````
Jordan Carlile
@jordan-carlile
Sep 30 2015 05:05
Hi guys
would anyone here be willing to look over some of my code for one of the basic bonfires?
Herman Fassett
@HermanFassett
Sep 30 2015 05:06
@jordan-carlile sure
Jordan Carlile
@jordan-carlile
Sep 30 2015 05:06
this is my somewhat broken solution for this bonfire
Herman Fassett
@HermanFassett
Sep 30 2015 05:07
Mk
Looks close
darien23
@darien23
Sep 30 2015 05:10
Hi can someone help me , im having trouble adding a class to my img element
Herman Fassett
@HermanFassett
Sep 30 2015 05:10
@darien23 sure
darien23
@darien23
Sep 30 2015 05:11
OK thanks. Ive been trying to figure it out for some time now, lol
CamperBot
@camperbot
Sep 30 2015 05:11
if you want to thank someone, put an @ before their name!
Herman Fassett
@HermanFassett
Sep 30 2015 05:11
lol ok what've you tried
@jordan-carlile mine was similar but I'm trying to find out why yours doesn't work
darien23
@darien23
Sep 30 2015 05:14
@HermanFassett this is what im suppose to do. -Your img element should have the class smaller-image. Also, Your image should be 100 pixels wide. This is what i have so far <style>
img{width: 100px;}
<img class="smaller.image"/>
</style>
<img src="https://bit.ly/fcc-relaxing-cat"/>
Jordan Carlile
@jordan-carlile
Sep 30 2015 05:15
@HermanFassett thanks can we PM?
CamperBot
@camperbot
Sep 30 2015 05:15
jordan-carlile sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 230 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Sep 30 2015 05:15
Sure
@darien23 first the class should be in the same img tab
tag*
like `<img class="smaller-image" src="https://whatever">`
darien23
@darien23
Sep 30 2015 05:16
Ok, let me try that.
Herman Fassett
@HermanFassett
Sep 30 2015 05:16
And did you create a class smaller-image?
darien23
@darien23
Sep 30 2015 05:18
i tried to, i just got really confused
Herman Fassett
@HermanFassett
Sep 30 2015 05:18
Since they wanted you to accomplish it with a class it shouldn't be `img{width: 100px;}` but rather `.smaller-image{ width: 100px;}
``````.smaller-image {
width: 100px;
}``````
a `.` indicates a class
darien23
@darien23
Sep 30 2015 05:22
@HermanFassett Hm. Should i type that above the line we just did with img scr
I tried above and it wont take it
Herman Fassett
@HermanFassett
Sep 30 2015 05:22
That should be in the styles
darien23
@darien23
Sep 30 2015 05:24

</style>

<h2 class="red-text">CatPhotoApp</h2>
.smaller-image {
width: 100px;}
<img class="smaller-image" src="https://bit.ly/fcc-relaxing-cat">

this is how i tried it
Herman Fassett
@HermanFassett
Sep 30 2015 05:25
The `.smaller-image {}` is a CSS class so it should go inbetween the style tags
So inbetween `<style>` and `</style>` because it's not Javascript
darien23
@darien23
Sep 30 2015 05:26
isnt that how i ave it ?
have
Herman Fassett
@HermanFassett
Sep 30 2015 05:26
No, yours is inside the javascript code
See how it comes after the closing </style> tag? That means it's in the javascript code
darien23
@darien23
Sep 30 2015 05:29
Im confused lol. im sorry, can you show me an example, i appreciate it
I know its simple, somehow ive been stuck on it for an hour
Herman Fassett
@HermanFassett
Sep 30 2015 05:29
Don't want to completely give it away unless that's what you want
darien23
@darien23
Sep 30 2015 05:30
ok, let me keep trying
Herman Fassett
@HermanFassett
Sep 30 2015 05:30
In between style tags like
``````<style>
.smaller-image {
width: 100px;
}
</style>``````
darien23
@darien23
Sep 30 2015 05:32
Ok, lol. i finally got it. Thanks, I had to put it above the <style>
CamperBot
@camperbot
Sep 30 2015 05:32
if you want to thank someone, put an @ before their name!
darien23
@darien23
Sep 30 2015 05:32
@HermanFassett thanks
Herman Fassett
@HermanFassett
Sep 30 2015 05:32
No problem ;)
Reggie
@Reggie01
Sep 30 2015 05:35
@jordan-carlile what error are you getting from your code?
Eduard Voinea
@edvoinea
Sep 30 2015 05:38
Bonfire: Map the Debris
hint
CamperBot
@camperbot
Sep 30 2015 05:38
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:

## :fire:Bonfire: Map the Debris :link:

``````function orbitalPeriod(arr) {
var GM = 398600.4418;
return arr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);``````

Return a new array that transforms the element's average altitude into their orbital periods.

more info:  `bf details` | `bf links` | `hint`

Herman Fassett
@HermanFassett
Sep 30 2015 05:39
Oh that one :P
azaleas
@azaleas
Sep 30 2015 06:11

Hi campers,

I'm doing Sum All Prime Numbers Bonfire:

``````function sumPrimes(num) {

arr = [2];
temp = [];
var n = 1;
var result = 0;

// create an array of numbers from 3 to num

for (var i = 3; i <= num; i++){
temp.push(i);

}

// check if the number can be divided by 2, if yes then it's not a prime number

for (var y=0; y <=temp.length; y++){
if (temp[y] % 2 == 0){
continue;
}

// number isn't divided by 2
else {

// take square root of the number and round it to bigger number
squroot = Math.ceil(Math.sqrt(temp[y]));

//check if the number can be divided to any numbers below the square root (square root included)

for (var x=2; x<=squroot; x++){
if (temp[y] % x !=0){
n++;
}

// number can't be divided to any number below the square root. Push it to array

if (n==squroot){
n=1;
arr.push(temp[y]);
}
}
}
}

//sum all the numbers in array

for (var z = 0; z<arr.length; z++){
result = result + arr[z];
}

return result;
}

sumPrimes(977);``````

result works for 10. But for 977 I get an error.

``expect(sumPrimes(977)).to.equal(73156);expected 226647 to equal 73156``

even though I get 226647 as a result for array.

darien23
@darien23
Sep 30 2015 06:15
hello can someone help me with anchor elements
Herman Fassett
@HermanFassett
Sep 30 2015 06:17
@darien23 sure x)
darien23
@darien23
Sep 30 2015 06:19
These are my instructions- Your "a" element should have the anchor text of "cat photos"
You need an "a" element that links to http://freecatphotoapp.com.
Make sure your "a" element has a closing tag.
Herman Fassett
@HermanFassett
Sep 30 2015 06:20
Ok, where are you stuck?
@azaleas I would recommend splitting it into two functions, one to check if the number is prime the other to loop through numbers under num and add them if they pass the other function... Makes it more readable I think
darien23
@darien23
Sep 30 2015 06:24
this it the link in the code they gave me
is
should i be trying to apply the instruction to this line of code
Herman Fassett
@HermanFassett
Sep 30 2015 06:26
No, that has nothing to do with this waypoint
You'll be creating your own <a> element somewhere below the style tags
darien23
@darien23
Sep 30 2015 06:28
ok, let me give it a shot
darien23
@darien23
Sep 30 2015 06:39
@HermanFassett I got it, ty
Herman Fassett
@HermanFassett
Sep 30 2015 06:40
@darien23 You're welcome ;)
DTing
@dting
Sep 30 2015 06:42
bf sum
CamperBot
@camperbot
Sep 30 2015 06:42

## :fire:Bonfire: Sum All Numbers in a Range :link:

``````function sumAll(arr) {
return(1);
}

sumAll([1, 4]);``````

We'll pass you an array of two numbers. Return the sum of those two numbers and all numbers between them.

more info:  `bf details` | `bf links` | `hint`

DTing
@dting
Sep 30 2015 06:42
bf prime
CamperBot
@camperbot
Sep 30 2015 06:42

## :fire:Bonfire: Sum All Primes :link:

``````function sumPrimes(num) {
return num;
}

sumPrimes(10);``````

Sum all the prime numbers up to and including the provided number.

more info:  `bf details` | `bf links` | `hint`

Ezekiel dela Peña
@ezekielvdp
Sep 30 2015 06:49
bf details
CamperBot
@camperbot
Sep 30 2015 06:49

## :fire:Bonfire: Sum All Primes :link:

``````function sumPrimes(num) {
return num;
}

sumPrimes(10);``````
Sum all the prime numbers up to and including the provided number.
A prime number is defined as having only two divisors, 1 and itself. For example, 2 is a prime number because it's only divisible by 1 and 2. 1 isn't a prime number, because it's only divisible by itself.
The provided number may not be a prime.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
Ezekiel dela Peña
@ezekielvdp
Sep 30 2015 06:50
bf DNA
CamperBot
@camperbot
Sep 30 2015 06:50

``````function pair(str) {
return str;
}

pair("GCG");``````

The DNA strand is missing the pairing element. Match each character with the missing element and return the results as a 2d array.

more info:  `bf details` | `bf links` | `hint`

Ezekiel dela Peña
@ezekielvdp
Sep 30 2015 06:52
bf hint
CamperBot
@camperbot
Sep 30 2015 06:52
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
darien23
@darien23
Sep 30 2015 06:57
@HermanFassett you still there?
darien23
@darien23
Sep 30 2015 07:02
can someone give me assistance?
Jason
@Jauble
Sep 30 2015 07:08
What do you need help with @darien23 ?
darien23
@darien23
Sep 30 2015 07:11
Replace your anchor element's href attribute with a #, also known as a hash symbol, to turn it into a dead link.
Jason
@Jauble
Sep 30 2015 07:13
Is your question where to put the #?
darien23
@darien23
Sep 30 2015 07:13
im not sure where / or how i should place the #
Jason
@Jauble
Sep 30 2015 07:14
Ok, paste what you think the anchor element's href attribute is
the attribute's value
darien23
@darien23
Sep 30 2015 07:15
Im having trouble understanding what exactly im trying to do. should i be looking for somewhere to put the # symbol , or should i change the code
Jason
@Jauble
Sep 30 2015 07:16
all you need to do is to change the value of href to #
darien23
@darien23
Sep 30 2015 07:18
@Jauble thanks, i understand now. ty
CamperBot
@camperbot
Sep 30 2015 07:18
:star: 186 | @jauble | http://www.freecodecamp.com/jauble
Jason
@Jauble
Sep 30 2015 07:18
Did you get it?
CamperBot
@camperbot
Sep 30 2015 07:18
darien23 sends brownie points to @jauble :sparkles: :thumbsup: :sparkles:
Avil
@Avil172
Sep 30 2015 07:18

hi.. can anyone help?

``Math.floor((Math.random() * 10) + 1);``

I found that this gives a random number between 1 and 10.
but how?
Math.random should be 9.99 at maximum, multiplying it with 10 makes it 9.9, and adding 1 to it makes it 10.9, which is greater than 10.

darien23
@darien23
Sep 30 2015 07:19
yea i got it .
Jason
@Jauble
Sep 30 2015 07:19
No problem, glad I could help!
Sukarno M. Sukarno
@sukarno1234
Sep 30 2015 07:22
can anyone explain me this code. \$(\$(".slot")[0]).html();
Jason
@Jauble
Sep 30 2015 07:23
Math.ceil rounds up
@Avil172
I'm not that familiar with jQuery @sukarno1234 but it looks like it grabs the first instance of the slot class and empties it's html.
DTing
@dting
Sep 30 2015 07:28
@sukarno1234 \$() creates a jquery object from a dom object.
Avil
@Avil172
Sep 30 2015 07:29
@Jauble understood.
thank you very much
CamperBot
@camperbot
Sep 30 2015 07:29
avil172 sends brownie points to @jauble :sparkles: :thumbsup: :sparkles:
:star: 187 | @jauble | http://www.freecodecamp.com/jauble
DTing
@dting
Sep 30 2015 07:30
\$(".slot") selects all the elements that have the class slot. the bracket notation returns a dom object instead of a jquery object so they wrap it using the outside \$()
it could also be writen as `\$(".slot").eq(0).html();` or `\$(".slot:eq(0)").html();`
Jason
@Jauble
Sep 30 2015 07:31
No problem, I'd listen to @dting dting though. He's more familiar with jQuery than I am.
Sukarno M. Sukarno
@sukarno1234
Sep 30 2015 07:44
thanks @dting
CamperBot
@camperbot
Sep 30 2015 07:44
sukarno1234 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1280 | @dting | http://www.freecodecamp.com/dting
Avishay
@avishayshushan
Sep 30 2015 07:55
bf pairwise
CamperBot
@camperbot
Sep 30 2015 07:55

``````function pairwise(arr, arg) {
return arg;
}

pairwise([1,4,2,3,0,5], 7);``````

Return the sum of all indices of elements of 'arr' that can be paired with one other element to form a sum that equals the value in the second argument 'arg'. If multiple sums are possible, return the smallest sum. Once an element has been used, it cannot be reused to pair with another.

more info:  `bf details` | `bf links` | `hint`

Avishay
@avishayshushan
Sep 30 2015 07:56
i need examples for input/output
it is not clear to me what the function should do
the "if multiple sums are...." line confusing me
Avil
@Avil172
Sep 30 2015 08:29
can someone tell me what does this mean..while(name) and while(name="x")
i know that the second one is a condition, but what about the first one?
Michelle Z
@mzulli
Sep 30 2015 08:32
@Avil172 the first one is also a condition. it means while name evaluates to true
if name was null, for example, it would evaluate to false
Luis Felipe López G.
@luishendrix92
Sep 30 2015 08:38
This message was deleted
negative numbers don't count as false though, just careful on that
So the while loop will execute (first condition) if and only if name -> has something in it that's not equal to 0, null, undefined, "", NaN, false
Uhh I deleted my previous msg by accident
Mateja Trifunovski
@Matko95
Sep 30 2015 09:05
@Avil172 while(name) means while name >0 or while name is true
Aleksandar B.
@aleksandar-b
Sep 30 2015 09:23
@Matko95 it means while name is true : hasn't have some of the 6 falsey values like not equal to 0, null, undefined, "", NaN and false. It can be zero but it can be also other 5 values, it depends.
Michelle Z
@mzulli
Sep 30 2015 09:31
MD MOJIBUL HOQUE
@Mojibul
Sep 30 2015 09:42
Dear developer i need your help.
I am stuck in Bonfire: Check for Palindromes

function palindrome(str) {
// Good luck!
str = str.replace("[^A-Za-z]+", "").toLowerCase();

}

Aleksandar B.
@aleksandar-b
Sep 30 2015 09:49
@Mojibul `str = str.replace(/[\W_]/g, '').toLowerCase();`
MD MOJIBUL HOQUE
@Mojibul
Sep 30 2015 09:51
Thanks @samosale but I don't understand how to reverse the string
CamperBot
@camperbot
Sep 30 2015 09:51
mojibul sends brownie points to @samosale :sparkles: :thumbsup: :sparkles:
:star: 282 | @samosale | http://www.freecodecamp.com/samosale
kaushalmathpal
@kaushalmathpal
Sep 30 2015 09:55
i need to create gray-background with the background-color of gray and assign it to div element
MD MOJIBUL HOQUE
@Mojibul
Sep 30 2015 09:55
kaushalmathpal
@kaushalmathpal
Sep 30 2015 09:55
div .gray-background {background-color:green;}-- M USING THIS CODE
Aleksandar B.
@aleksandar-b
Sep 30 2015 09:55
@Mojibul you need to convert each letter in a string to array with split(), then use reverse() on that array to reverse it and then convert that reversed array to string using join(). But be carefull, split() and join() should have some sign in parenthesis. It's up to you to discover what sign. And assign to each method new variable to hold value
MD MOJIBUL HOQUE
@Mojibul
Sep 30 2015 09:58
Thanks @samosale I got the smart solutions str == str.split('').reverse().join('')
CamperBot
@camperbot
Sep 30 2015 09:58
mojibul sends brownie points to @samosale :sparkles: :thumbsup: :sparkles:
:warning: mojibul already gave samosale points
Aleksandar B.
@aleksandar-b
Sep 30 2015 09:58

@kaushalmathpal give a div element whatever class you want, and then in Css, type that class. Example

``<div class="mycolor"><div>``

in Css type

``````.mycolor{
background-color:gray;
}``````
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:12
@samosale its not working
Aleksandar B.
@aleksandar-b
Sep 30 2015 10:13
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:14
@samosale Create a class called gray-background with the background-color of gray. Assign this class to your div element.
Aleksandar B.
@aleksandar-b
Sep 30 2015 10:15

@kaushalmathpal

``<div class="gray-background"><div>``

in Css type

``````.gray-background{
background-color:gray;
}``````
@kaushalmathpal is that a CSS chalenge or jQuery?
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:17
@samosale HTML & CSS
Aleksandar B.
@aleksandar-b
Sep 30 2015 10:19
@kaushalmathpal is it working?
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:20
no
Aleksandar B.
@aleksandar-b
Sep 30 2015 10:21
@kaushalmathpal send me url of that Waypoint
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:21
Aleksandar B.
@aleksandar-b
Sep 30 2015 10:23
@kaushalmathpal between style tags type ```.gray-background{ background-color:gray; }```
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:24
done
how to assign it to div
@samosale done how to assign it to div..
Aleksandar B.
@aleksandar-b
Sep 30 2015 10:25
@kaushalmathpal first div tag should look like this`<div class="gray-background">`
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:26
@samosale done...thanks a lot
CamperBot
@camperbot
Sep 30 2015 10:26
kaushalmathpal sends brownie points to @samosale :sparkles: :thumbsup: :sparkles:
:star: 283 | @samosale | http://www.freecodecamp.com/samosale
kaushalmathpal
@kaushalmathpal
Sep 30 2015 10:27
@camperbot how can i send the brownie point...m new to coding and gitterhub
Michelle Z
@mzulli
Sep 30 2015 10:29
@kaushalmathpal camperbot sends brownie points when you thank someone
CamperBot
@camperbot
Sep 30 2015 10:29
mzulli sends brownie points to @kaushalmathpal :sparkles: :thumbsup: :sparkles:
:star: 39 | @kaushalmathpal | http://www.freecodecamp.com/kaushalmathpal
This is what I have but it keeps saying "missing ) after argument list"
``````    \$(\$('.slot')[0]).html('<img src ="'+ images[slotOne-1]+'">');
\$(\$('.slot')[1]).html('<img src ="'+ images[slotTwo-1]+'">');
\$(\$('.slot')[2]).html('<img src ="'+ images[slotThree-1]'">');``````
Nvm I got it
Abhisek Pattnaik
@abhisekp
Sep 30 2015 12:05

## Help bf Pairwise

I don't understand this statement "If multiple sums are possible, return the smallest sum." given the example

For example, pairwise([1, 4, 2, 3, 0, 5], 7) should return 11 because 4, 2, 3 and 5 can be paired with each other to equal 7.

CamperBot
@camperbot
Sep 30 2015 12:05
no wiki entry for: `bf pairwisei dont understand this statement if multiple sums are possible return the smallest sum given the example for example pairwise1 4 2 3 0 5 7 should return 11 because 4 2 3 and 5 can be paired with each other to equal 7`
:pencil: click here to create one now!after creating your page type `update` to reload it here
Avishay
@avishayshushan
Sep 30 2015 12:09
@abhisekp i think it means that you cannot use the same index twice
Abhisek Pattnaik
@abhisekp
Sep 30 2015 12:09

@avishayshushan that has been written in another statement

Once an element has been used, it cannot be reused to pair with another.

Avishay
@avishayshushan
Sep 30 2015 12:10
@abhisekp and you need to take the lowest index that pair with it
@abhisekp lets say [1,2,2],3 will return 1
and [1,2,1,2],3 will return 6
Abhisek Pattnaik
@abhisekp
Sep 30 2015 12:12
@avishayshushan so?
@avishayshushan ????
Avishay
@avishayshushan
Sep 30 2015 12:15
@abhisekp so when you find the same pair with values (but different index) you need to add them to the sum
but if the same index&value can pair with 2 different indexes with the same value u will only add the lowest index
sorry for the poor english
if it does not help i don't think i can bring you a better one
maybe some one else can assist ?
Abhisek Pattnaik
@abhisekp
Sep 30 2015 12:16
Avishay
@avishayshushan
Sep 30 2015 12:17
@abhisekp great!
Abhisek Pattnaik
@abhisekp
Sep 30 2015 12:18
@avishayshushan your statement before and after but are contradictory but I get it. Thanks
CamperBot
@camperbot
Sep 30 2015 12:18
abhisekp sends brownie points to @avishayshushan :sparkles: :thumbsup: :sparkles:
:star: 260 | @avishayshushan | http://www.freecodecamp.com/avishayshushan
Godson Justin
@Gvon05
Sep 30 2015 12:28
Hello people
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 12:28
Got a question here... I noticed the tests at the end of each code in the Bonfire exercises often have an extra argument. Do they have any significance I may be overlooking?
Godson Justin
@Gvon05
Sep 30 2015 12:28
I am new in here....got a question
Jonathan Lee Slew
@jlslew
Sep 30 2015 12:29
@IshMary not sure what you are talking about, would you mind posting an example?
ustafurkn
@ustafurkn
Sep 30 2015 12:34
Give your form element the id of cat-photo-form.
```html
how can i do this ?
minakasiin
@minakasiin
Sep 30 2015 12:35
camperbot wiki
wiki code
CamperBot
@camperbot
Sep 30 2015 12:36

## :point_right: -----

undefined
:pencil: -----
Jonathan Lee Slew
@jlslew
Sep 30 2015 12:41

@ustafurkn, here is a p tag

``<p>Hello World!</p>``

and here is the same p tag with an id

``<p id="greeting">Hello World!</p>``
minakasiin
@minakasiin
Sep 30 2015 12:42
oh, i thought he wanted to paste the code. Tried to look for the wiki for that with camperbot, but I don't remember what was it called :(
Godson Justin
@Gvon05
Sep 30 2015 12:42
Am in a basic lesson of using CSS, please help me to write this line properly; <style>h2 {color: blue;} CatPhotoApp </style>.
minakasiin
@minakasiin
Sep 30 2015 12:44
@Gvon05 CatPhotoApp should not be in the <style></style> I believe.
```
``````<style>h2 {color: blue;}  </style>
CatPhotoApp``````
Maybe like this?
Godson Justin
@Gvon05
Sep 30 2015 12:45
Okay, let me try that
Still does not work @minakasiin
Corey Murray
@muzzaaa
Sep 30 2015 12:47
@Gvon05 the <style> is only used to apply an attribute to something, such as colour or size for example. You will then apply the colour blue to "CatPhotoApp" because it will be placed within <h2> ""</h2>
read the instruction again, i'm sure it is meant to be red
minakasiin
@minakasiin
Sep 30 2015 12:48
Oh yea, sorry, forgot to add the <h2> taggs for CatPhotoApp.
Godson Justin
@Gvon05
Sep 30 2015 12:50
Okay, got it! thank you @minakasiin and @muzza96
CamperBot
@camperbot
Sep 30 2015 12:50
gvon05 sends brownie points to @minakasiin and @muzza96 :sparkles: :thumbsup: :sparkles:
:star: 196 | @minakasiin | http://www.freecodecamp.com/minakasiin
:star: 44 | @muzza96 | http://www.freecodecamp.com/muzza96
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 12:53
Something like this ```js
``chunk(["a", "b", "c", "d"], 2, "");``
@jlslew That's it above
The empty string argement
Please I'm on the Chunky Monkey exercise
Need some help. My code is returning an integer
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 12:58
``````function chunk(arr, size) {
// Break it up.
var newArr = [];
var removed = [];
for(var count = 0; count < size; count++){
removed = arr.splice(size, 0 );
newArr = arr.push(removed);
}
return newArr;
}

chunk(["a", "b", "c", "d"], 2, "");``````
Jonathan Lee Slew
@jlslew
Sep 30 2015 12:58
@IshMary there wasn't any empty string when I did that challenge, i'd say ignore it
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 12:59
I ignore them all without any side effects so far. Just wondering... Kindly help with the above @jlslew
``````function chunk(arr, size) {
// Break it up.
var newArr = [];

for(var count = 0; count < size; count++){
var removed = arr.splice(0, size);
return newArr.push(removed);
}
//  return newArr;
}

chunk(["a", "b", "c", "d"], 2);``````
minakasiin
@minakasiin
Sep 30 2015 13:02
`` bw = str.split(' ').replace("," , "").join('').toLowerCase();``
Where should I put the .replace in this current line? Currently it gives me "str.replace is not a function.
Jonathan Lee Slew
@jlslew
Sep 30 2015 13:02
@IshMary the return statement should be outside the loop
@minakasiin before the split because split returns an array
minakasiin
@minakasiin
Sep 30 2015 13:03
yeah, found it alraedy :D
I have to put it after .join
or before split. Thanks @jlslew
CamperBot
@camperbot
Sep 30 2015 13:04
minakasiin sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 250 | @jlslew | http://www.freecodecamp.com/jlslew
Srdjan1
@Srdjan1
Sep 30 2015 13:24
Need help for Waypoint: Declare JavaScript Variables
pls
Godson Justin
@Gvon05
Sep 30 2015 13:24

CatPhotoApp</h2>

Herman Fassett
@HermanFassett
Sep 30 2015 13:24
@Gvon05 what've you tried?
Godson Justin
@Gvon05
Sep 30 2015 13:25
h2 element to be red
Srdjan1
@Srdjan1
Sep 30 2015 13:25

// var ourName = "Free Code Camp";

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
// You'll learn about functions soon.

if(typeof(myName) !== "undefined"){(function(v){return v;})(myName);}

Godson Justin
@Gvon05
Sep 30 2015 13:25
@HermanFassett
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 13:25
Ok @jlslew
Same result
Herman Fassett
@HermanFassett
Sep 30 2015 13:26
@Srdjan1 so create a var like ourName but called myName that is your name (and also not commented)
OK @Gvon05 what've you tried
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 13:26
@jlslew
``````function chunk(arr, size) {
// Break it up.
var newArr = [];

for(var count = 0; count < size; count++){
removed = arr.splice(size, 0 );
newArr = arr.push(removed);
}
return newArr;
}

chunk(["a", "b", "c", "d"], 2, "");``````
Blauelf
@Blauelf
Sep 30 2015 13:27
@IshMary `newArr.push(removed);` instead of `newArr = arr.push(removed);`
And the splice parameters were right with 0,size
Jason Wood
@catapixel
Sep 30 2015 13:28
@IshMary ^ is correct
Blauelf
@Blauelf
Sep 30 2015 13:31
And you should think about your loop condition. count<size looks not so promising. Maybe `while(arr.length)` is a better one.
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 13:34
@Blauelf still returning an integer.
And why the preference for while
Herman Fassett
@HermanFassett
Sep 30 2015 13:35
Cleaner and much more clever
And it works
Blauelf
@Blauelf
Sep 30 2015 13:35

You have implemented

@IshMary `newArr.push(removed);` instead of `newArr = arr.push(removed);`
?

Godson Justin
@Gvon05
Sep 30 2015 13:36
I have tried to make h2 to be red but I have failed, please help how should I write it @HermanFassett
Herman Fassett
@HermanFassett
Sep 30 2015 13:37
@Gvon05 your h2 stuff looked right. What does your red-text class look like?
EngineeredEdge
@EngineeredEdge
Sep 30 2015 13:40
help bootstrap
CamperBot
@camperbot
Sep 30 2015 13:40

## :point_right: bootstrap [wiki]

A frontend CSS framework.

You can find out more here

related: css, frameworks

Blauelf
@Blauelf
Sep 30 2015 13:40
@IshMary The way you work on the array, you change it. You would have to compute the number of sub-arrays before you enter the loop and compare with that instead of size. The while loop is easier, and you don't use your counter anywhere.
EngineeredEdge
@EngineeredEdge
Sep 30 2015 13:40
help framework
CamperBot
@camperbot
Sep 30 2015 13:40
no wiki entry for: `framework`
:pencil: click here to create one now!after creating your page type `update` to reload it here
Godson Justin
@Gvon05
Sep 30 2015 13:41
<h2 class="red-text" >CatPhotoApp</h2>
@HermanFassett
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 13:42
Ok boss @Blauelf . Looking into that.
Herman Fassett
@HermanFassett
Sep 30 2015 13:42
@Gvon05 that's correct, then you need the `.red-text` class inside of your styles
Godson Justin
@Gvon05
Sep 30 2015 13:42
how do I type it? @HermanFassett
EngineeredEdge
@EngineeredEdge
Sep 30 2015 13:43
<style>
``````<style>
.red-text {
##styling##
}
</style>``````
Herman Fassett
@HermanFassett
Sep 30 2015 13:43
Yes, like @EngineeredEdge said
Blauelf
@Blauelf
Sep 30 2015 13:44
@IshMary The number of subarrays would be `Math.ceil(arr.length/size)`, if you really want to use it. Just make sure to store it before you make the first changes to arr.
EngineeredEdge
@EngineeredEdge
Sep 30 2015 13:44
@Gvon05 , everything that goes in the 'style' element is known as the 'style sheet.' It allows you to define styling for use on multiple elements on your page
the period, '.', declares that the styling should apply to all elements with that class
``````<style>
.apples {
background-color: red;
color: green;
}
</style>``````
That tells the page to go through all the elements of the page, find the ones that have class 'apples', and make their background color red and text-color green
Godson Justin
@Gvon05
Sep 30 2015 13:48
Thank you, but now I am supposed to use this <h2 class="blue-text">CatPhotoApp</h2> for styling. "Waypoint: Use a CSS Class to Style an Element" @EngineeredEdge
CamperBot
@camperbot
Sep 30 2015 13:48
gvon05 sends brownie points to @engineerededge :sparkles: :thumbsup: :sparkles:
:star: 246 | @engineerededge | http://www.freecodecamp.com/engineerededge
Herman Fassett
@HermanFassett
Sep 30 2015 13:49
:/
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 13:49
Ok @Blauelf
Blauelf
@Blauelf
Sep 30 2015 13:51
The chunky bf does not specify what happens to holes in the array. @IshMary 's solution conserves them, which is probably right.
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 13:52
:-)
I somtimes don't consider all the possibilities except when the tests point them out.
But @Blauelf, won't while(arr.length) be true every time?
Blauelf
@Blauelf
Sep 30 2015 13:54
Holes in arrays are a concept that I wasn't aware of before I hit Javascript. It is somewhat exotic, I think, but consistent with how arrays and array-like objects work.
Mizzix
@Mizzix
Sep 30 2015 13:55
@IshMary I did something along these lines just now:
``````function chunk(arr, size) {
// Break it up.
var i = 0;
var finArray = [];

while (arr.length > 0) {

var tempArray = arr.splice(0,size);
finArray[i] = tempArray;
i = i + 1;

}

return finArray;
}``````
Blauelf
@Blauelf
Sep 30 2015 13:55
@IshMary You remove a part of arr everytime, and once arr.length becomes 0, it evaluates to false.
Mizzix
@Mizzix
Sep 30 2015 13:56
I’m not sure how much of that is redundant… rubs head and drinks more coffee
Blauelf
@Blauelf
Sep 30 2015 13:56
@Mizzix Why no more push?
Works, though.
Mizzix
@Mizzix
Sep 30 2015 13:57
It runs..but I’m not sure if I could streamline the code more. ^_^
Blauelf
@Blauelf
Sep 30 2015 13:57
`i = i + 1` could be written as `i += 1` or even `i++` :)
Mizzix
@Mizzix
Sep 30 2015 13:58
thanks @Blauelf ! I had that but it was returning “missing ; before statement” until I rewrote it to “i = i+1” :)
CamperBot
@camperbot
Sep 30 2015 13:58
mizzix sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 319 | @blauelf | http://www.freecodecamp.com/blauelf
Mizzix
@Mizzix
Sep 30 2015 13:59
And now the “i++” works again. needs more coffee thanks again for the ideas :)
CamperBot
@camperbot
Sep 30 2015 13:59
if you want to thank someone, put an @ before their name!
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 14:01
Mizzix
@Mizzix
Sep 30 2015 14:01
OMG THANK YOU SO MUCH @IshMary ;-)
CamperBot
@camperbot
Sep 30 2015 14:01
mizzix sends brownie points to @ishmary :sparkles: :thumbsup: :sparkles:
:star: 183 | @ishmary | http://www.freecodecamp.com/ishmary
Mizzix
@Mizzix
Sep 30 2015 14:01
sorry, just a bit of humor…no offense meant ^_^
these Bonfires make me want to poke my eyes out sometimes. chugs away
Blauelf
@Blauelf
Sep 30 2015 14:03

@Mizzix Somewhat more... integrated version of your code

``````function chunk(arr, size) {
// Break it up.
var i = 0;
var finArray = [];

while (arr.length)
finArray[i++] = arr.splice(0,size);  // or finArray.push(arr.splice(0,size)); without need for any i

return finArray;
}``````

Remember to use i++ here, not ++i.

Mizzix
@Mizzix
Sep 30 2015 14:03
oooooh. I like the i++ inside the array designation!
and there’s no need to monitor arr.length because it will eventually evaluate to 0?
Mateja Trifunovski
@Matko95
Sep 30 2015 14:04
@Blauelf won't that start from i=1; then?
Mizzix
@Mizzix
Sep 30 2015 14:04
looks like it
Blauelf
@Blauelf
Sep 30 2015 14:04
Cannot become negative, and will evaluate as true if not 0.
@Matko95 That's why I use i++ and not ++i.
i++ increments after evaluation. ++i increments before.
Mizzix
@Mizzix
Sep 30 2015 14:05
does the program read ‘i’ as 0 then add 1 in that case?
got it…cool @Blauelf thanks
CamperBot
@camperbot
Sep 30 2015 14:05
mizzix sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: mizzix already gave blauelf points
Mateja Trifunovski
@Matko95
Sep 30 2015 14:06
@Blauelf oh cool didn't know that :) thanks
CamperBot
@camperbot
Sep 30 2015 14:06
matko95 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 320 | @blauelf | http://www.freecodecamp.com/blauelf
x34passenger
@x34passenger
Sep 30 2015 14:09
is it possible to dynamically create variables using a for loop?
Blauelf
@Blauelf
Sep 30 2015 14:09
What do you mean?
x34passenger
@x34passenger
Sep 30 2015 14:09
@Blauelf Bonfire: Symmetric Difference
@Blauelf what is the best way to coding this bonfire?
Jason Wood
@catapixel
Sep 30 2015 14:10
@x34passenger yes you could but you wouldn't want to solve a problem that way
x34passenger
@x34passenger
Sep 30 2015 14:10
Blauelf
@Blauelf
Sep 30 2015 14:10
@x34passenger I filtered each array for elements not in the other and then concatenated those.
Jason Wood
@catapixel
Sep 30 2015 14:12
@x34passenger @Blauelf 's solution would work or you could use their suggested Array.reduce() method to work through them. You just need to make sure to loop over every array that is provided which should be something you're already used to doing...
x34passenger
@x34passenger
Sep 30 2015 14:13
@catapixel I am not sure how to use the Array.reduce() in this Bonfire. Can you show a code example?
Jason Wood
@catapixel
Sep 30 2015 14:14
@x34passenger there are examples of how to use it if you follow the link (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
x34passenger
@x34passenger
Sep 30 2015 14:15
Jason Wood
@catapixel
Sep 30 2015 14:15
@x34passenger when I solved it originally I just used the forEach method and indexOf to go through each array and push the "good" values to a new array
Blauelf
@Blauelf
Sep 30 2015 14:17
One can use reduce or a for loop to iterate through the variable number of arguments.
Jason Wood
@catapixel
Sep 30 2015 14:17

@x34passenger you could use reduce to do the following:

``````var flattened = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) {
return a.concat(b);
});
// flattened is [0, 1, 2, 3, 4, 5]``````

and then check to make sure only "non-repeated" values are kept in your final array.

x34passenger
@x34passenger
Sep 30 2015 14:17
@Blauelf I have an idea of how to use the for loop, but specifically how would I use the reduce in this bonfire?
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 14:17
@Blauelf Now I get an array
But my logic seems convoluted.
``````function chunk(arr, size) {
// Break it up.
var newArr = [];
var subs = Math.ceil(arr.length / size);
var i = 0;

while (arr.length < subs){
newArr.push(0, size);
i++;
}
return newArr;
}

chunk(["a", "b", "c", "d"], 2);``````
Plus the array is empty
x34passenger
@x34passenger
Sep 30 2015 14:18
@catapixel so you flatten the array and just remove all the duplicates?
Blauelf
@Blauelf
Sep 30 2015 14:18
@IshMary You lost the arr.splice
Jason Wood
@catapixel
Sep 30 2015 14:18
@x34passenger there are lots of ways to solve it but yes that is one way to do this
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 14:19
@Blauelf splice()?
Blauelf
@Blauelf
Sep 30 2015 14:19

@x34passenger My code looked like

``````function sym(args) {
return Array.prototype.slice.call(arguments).reduce((a,b)=>a.filter(c=>b.every(d=>c!=d)).concat(b.filter(c=>a.every(d=>c!=d))),[]).reduce((a,b)=>a.some(c=>c==b)?a:a.concat([b]),[]);
}``````

x34passenger
@x34passenger
Sep 30 2015 14:21
@Blauelf it is very obfuscated
Jason Wood
@catapixel
Sep 30 2015 14:21
@Blauelf yikes! I agree that's not very readable :wink:
x34passenger
@x34passenger
Sep 30 2015 14:21
@Blauelf it is a good source code anti-hacking strategy
Jason Wood
@catapixel
Sep 30 2015 14:21
@x34passenger if you want to see how I solved it I can show you as well. I just created a function to process the arrays....
Blauelf
@Blauelf
Sep 30 2015 14:21
@IshMary
``````function chunk(arr, size) {
// Break it up.
var newArr = [];
var subs = Math.ceil(arr.length / size);
var i = 0;

for(var i=0; i < subs; i++){
newArr.push(arr.splice(0, size)); // or newArr[i]=arr.splice(0,size);
}
return newArr;
}

chunk(["a", "b", "c", "d"], 2);``````
x34passenger
@x34passenger
Sep 30 2015 14:22
@catapixel I will try to implement it
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 14:23
COuld you implement it in a while loop @Blauelf ?
Jason Wood
@catapixel
Sep 30 2015 14:23
@x34passenger you can do it. just ask questions if you get stuck. These are the ones worth pushing through. I may go back and implement the reduce method myself. They have changed the bonfire since I did it. At the time they directions said you would only be supplied two arrays. Now it says two or more...
Mizzix
@Mizzix
Sep 30 2015 14:24
whee! works on Mutation BF
Blauelf
@Blauelf
Sep 30 2015 14:24
@IshMary That would be
``````function chunk(arr, size) {
// Break it up.
var newArr = [];

while(arr.length){
newArr.push(arr.splice(0, size));
}
return newArr;
}

chunk(["a", "b", "c", "d"], 2);``````
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 14:26
Ok. Thank you.
CamperBot
@camperbot
Sep 30 2015 14:26
if you want to thank someone, put an @ before their name!
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 14:26
@Blauelf Thank you
CamperBot
@camperbot
Sep 30 2015 14:26
ishmary sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 321 | @blauelf | http://www.freecodecamp.com/blauelf
Avil
@Avil172
Sep 30 2015 14:26
@mzulli @Matko95 thanks for the reply.
can we also write it like this? while(name===true)? or "true" needs to be mentioned inside quotes?
CamperBot
@camperbot
Sep 30 2015 14:26
avil172 sends brownie points to @mzulli and @matko95 :sparkles: :thumbsup: :sparkles:
:star: 230 | @mzulli | http://www.freecodecamp.com/mzulli
:star: 405 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 30 2015 14:27
@Avil172 you don't need quotes
Avil
@Avil172
Sep 30 2015 14:28
@Matko95 but for other strings, i need it, right?
Mateja Trifunovski
@Matko95
Sep 30 2015 14:28
@Avil172 if it's a string then yes, the quotes make it a string
Avil
@Avil172
Sep 30 2015 14:29
@Matko95 what about other loops such as if? i.e. if(name)? is it a valid syntax?
@Matko95 is that same as if(name===true)?
Blauelf
@Blauelf
Sep 30 2015 14:30
Those are different expressions.
Avil
@Avil172
Sep 30 2015 14:32
@Blauelf you mean if(name) is not same as if(name===true)?
Blauelf
@Blauelf
Sep 30 2015 14:33
name===true tests if name is exactly the same as true. Using only name will react to anything that Boolean(name) will return true for.
Boolean(name) will return false for values like null, 0, undefined, NaN, false, "", [].
Alexandrix Ikechukwu
@SpaghettiThots
Sep 30 2015 14:33
Is Slasher Flick bf to make me feel good?
Should be the easiest exercise in my coding horror
Mizzix
@Mizzix
Sep 30 2015 14:34
I agree @IshMary
Blauelf
@Blauelf
Sep 30 2015 14:35
And remember that true is a Boolean, and "true" is a string, they do not even compare loosely (==).
Avil
@Avil172
Sep 30 2015 14:35
@Blauelf uhh.. doesn't that make them same?
@Blauelf yeah i know about that.
Blauelf
@Blauelf
Sep 30 2015 14:36
Boolean() for those values is the same, but they themselves are not.
Well, null==undefined, but null!==undefined. (null loosely equals undefined, but not strictly)
Avil
@Avil172
Sep 30 2015 14:38
@Blauelf don't we use == in "c" and "===" in js?
there are so many similarities that i am getting confused.
Blauelf
@Blauelf
Sep 30 2015 14:39
== is compare loosely. "0"==0. === is compare strictly. "0"!==0.
Avil
@Avil172
Sep 30 2015 14:42
@Blauelf alright. thank you.
CamperBot
@camperbot
Sep 30 2015 14:42
avil172 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 322 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Sep 30 2015 14:43
So, in most cases, you want to use ===, unless you know why ==.
Avil
@Avil172
Sep 30 2015 14:43
@Blauelf ok
Blauelf
@Blauelf
Sep 30 2015 14:46
Is it better to convert to int by using ~~ or 0|? Is the latter really faster?
Shair Mir
@ShairMir
Sep 30 2015 14:50
wiki argument object
CamperBot
@camperbot
Sep 30 2015 14:50
no wiki entry for: `argument object`
:pencil: click here to create one now!after creating your page type `update` to reload it here
EngineeredEdge
@EngineeredEdge
Sep 30 2015 15:07
Is anyone here?
Blauelf
@Blauelf
Sep 30 2015 15:07
Guess so.
Herman Fassett
@HermanFassett
Sep 30 2015 15:08
:)
EngineeredEdge
@EngineeredEdge
Sep 30 2015 15:09
hola @Blauelf and @HermanFassett
how long have you guys been going through FCC?
x34passenger
@x34passenger
Sep 30 2015 15:09
how do you access multiple arguments in a function?
Blauelf
@Blauelf
Sep 30 2015 15:10
You mean using the arguments object?
Herman Fassett
@HermanFassett
Sep 30 2015 15:11
I joined September 4
Hugo
@hugoender
Sep 30 2015 15:11
@x34passenger elaborate and what you would like to do
EngineeredEdge
@EngineeredEdge
Sep 30 2015 15:11
@HermanFassett was that before or after they added the new tracks?
x34passenger
@x34passenger
Sep 30 2015 15:12
not sure how to use the arguments object to access each argument in Bonfire: Symmetric Difference
Herman Fassett
@HermanFassett
Sep 30 2015 15:12
After?
:P
How much coding / web dev experience did you have before FCC?
Herman Fassett
@HermanFassett
Sep 30 2015 15:14
I've been programming for a hobby now for some years so though nothing super concrete I had a bit of experience
x34passenger
@x34passenger
Sep 30 2015 15:14
thanks @EngineeredEdge @Blauelf
CamperBot
@camperbot
Sep 30 2015 15:14
x34passenger sends brownie points to @engineerededge and @blauelf :sparkles: :thumbsup: :sparkles:
:star: 249 | @engineerededge | http://www.freecodecamp.com/engineerededge
:star: 323 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Sep 30 2015 15:15
@x34passenger arguments is array-like, so you can iterate it with a basic for loop, but with the call from the reference website, you can copy its content into an array and use that instead, including reduce() if you want to.
x34passenger
@x34passenger
Sep 30 2015 15:15
thanks @Blauelf
CamperBot
@camperbot
Sep 30 2015 15:15
x34passenger sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: x34passenger already gave blauelf points
EngineeredEdge
@EngineeredEdge
Sep 30 2015 15:15
@HermanFassett and how far along are you now?
Herman Fassett
@HermanFassett
Sep 30 2015 15:18
I'm on Advanced Algorithm Scripting though I haven't finished a portfolio page
Blauelf
@Blauelf
Sep 30 2015 15:23
I don't really like frontend development, so my incomplete portfolio page has been untouched for a while now.
Is someone really using his portfolio page project as a portfolio page?
Herman Fassett
@HermanFassett
Sep 30 2015 15:25
lol
Hugo
@hugoender
Sep 30 2015 15:26
@blauelf i semi created the portfolio page just to learn css nuances. at some point i plan on going back and making it look nice and clean (unlike the example they give which is horrendous)
Pratik Ratnaparkhi
@pratikr1593
Sep 30 2015 15:27
how to make an object accessible publicly?
publically *
Hugo
@hugoender
Sep 30 2015 15:27
@blauelf the example is good for forcing yout to try to do different things within a page but making background images with text on top is just so.... bad
Blauelf
@Blauelf
Sep 30 2015 15:27
@pratikr1593 What do you mean?
You want a property on your object to be public?
Pratik Ratnaparkhi
@pratikr1593
Sep 30 2015 15:28
``````//Let's create an object with a two functions. One attached as a property and one not.
var Car = function() {
gear = 1;
return 'The Current Gear Is: ' + styleMe;
}
this.getGear = function() {
};
};

var Bike = function() {
// Only change code below this line.
getSpeed = function () {
speed = 100;
return value + "KM/H";
}

};

};

// Only change code above this line.
var myCar = new Car();
var myBike = new Bike();

if(myBike.hasOwnProperty('getSpeed')){(function() {return JSON.stringify(myBike.getSpeed());})();};``````
The method getSpeed of myBike should be accessible outside the object
@Blauelf
Isabelle Lepez
@Isabellle
Sep 30 2015 15:29
Hi all, I have a quick question
Hugo
@hugoender
Sep 30 2015 15:29
@pratikr1593 `myBike.getSpeed` does not work?
Blauelf
@Blauelf
Sep 30 2015 15:29
Then use this.getSpeed instead of getSpeed. this is the object to be created, attaching the function to it makes the function callable to anyone who has a handle to your object.
Isabelle Lepez
@Isabellle
Sep 30 2015 15:30
But I don't remember how to paste code here ;)
Hugo
@hugoender
Sep 30 2015 15:30
@millinet hello...
wiki markup
CamperBot
@camperbot
Sep 30 2015 15:30
no wiki entry for: `markup`
:pencil: click here to create one now!after creating your page type `update` to reload it here
Blauelf
@Blauelf
Sep 30 2015 15:30
help format
CamperBot
@camperbot
Sep 30 2015 15:30

## :point_right: code formatting [wiki]

### Inline code

This an inline ``<paste code here>`` code formatting with a single backtick(`) at start and end around the `code`.

### Code Block

``` ⇦ Type 3 backticks and then press `[shift + enter ⏎]`

``````<paste your code here>,
then press [shift + enter ⏎]``````

``` ⇦ Type 3 backticks, then press `[enter ⏎]`

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

Hugo
@hugoender
Sep 30 2015 15:30
@blauelf i can never remember how to get camperbot to do what i want lol
Blauelf
@Blauelf
Sep 30 2015 15:32
@hugoender "format", "formatting", and a few other words work for that. Also, it can be "wiki" or "help", maybe even more.
EngineeredEdge
@EngineeredEdge
Sep 30 2015 15:32
Waypoint: Add Font Awesome Icons to our Buttons ...........
Chris
@Shifthawke
Sep 30 2015 15:32
....
EngineeredEdge
@EngineeredEdge
Sep 30 2015 15:32
Font awesome does NOT come automatically with Bootstrap right?
Hugo
@hugoender
Sep 30 2015 15:32
no
Isabelle Lepez
@Isabellle
Sep 30 2015 15:33
Why the function "getFcc" called into the function "init" doesn't pass the variable fccDisplayName? I have put the keyword var or am I missing something?
``````(function(){

var app = angular.module('twitch', []);

app.controller('twitchController', ['\$http', function(\$http){

var twitchApi = 'https://api.twitch.tv/kraken/';
var fccUrl = 'users/freecodecamp';
var fccBio;
var fccDisplayName;

var getFcc = function(){
\$http({
method: 'GET',
url: twitchApi+fccUrl
}).then(function successCallback(response) {
fccDisplayName = response.data.display_name;
fccBio = response.data.bio;

}, function errorCallback(response) {
console.log(response);
});
}

var init = function(){
//set rows to have the same height
\$('.item').matchHeight();
});
console.log(fccDisplayName);
}

//We init the app
init();

}]);

})();``````
CamperBot
@camperbot
Sep 30 2015 15:33
:trollface: troll problems? notify admins here
EngineeredEdge
@EngineeredEdge
Sep 30 2015 15:33
so shouldn't we be linking to it before we use it @hugoender
the way the lesson is set up, it seems like it's just available to us
Hugo
@hugoender
Sep 30 2015 15:34
@millinet because that variable is local to that function
Pratik Ratnaparkhi
@pratikr1593
Sep 30 2015 15:34
@Blauelf No, I am confused where should I put it in
Hugo
@hugoender
Sep 30 2015 15:34
@millinet create the variable outside of the function so its accessible to other functions
Herman Fassett
@HermanFassett
Sep 30 2015 15:34
@hugoender it is
Hugo
@hugoender
Sep 30 2015 15:34
@engineerededge yes you are right but the lessons link to it for you i beliebe
@HermanFassett what is? lol
Isabelle Lepez
@Isabellle
Sep 30 2015 15:35
@hugoender even if I put the var outside the functions? (in the example getFcc(); is not called in init() lol, but when calling it it's undefined)
Herman Fassett
@HermanFassett
Sep 30 2015 15:35
@millinet I think GET is asynchronous
Hugo
@hugoender
Sep 30 2015 15:36
Herman Fassett
@HermanFassett
Sep 30 2015 15:36
@hugoender :)
Isabelle Lepez
@Isabellle
Sep 30 2015 15:37
@hugoender ;) no prob
Herman Fassett
@HermanFassett
Sep 30 2015 15:37
@millinet where do you actually call getFcc()?
Isabelle Lepez
@Isabellle
Sep 30 2015 15:38
In the init function (here in the example I forgot it, wait a sec)
Blauelf
@Blauelf
Sep 30 2015 15:39
@pratikr1593 Something like this
``````var Bike = function() {
// Only change code below this line.
var speed = 100;
return value + "KM/H";
}

this.getSpeed = function () {
};

};``````
Herman Fassett
@HermanFassett
Sep 30 2015 15:39
@millinet I think it's because GET Is asynchronous meaning it might still be running and therefore not have defined your variable before you output it
Hugo
@hugoender
Sep 30 2015 15:40
@millinet yeah you may want to use the `.status` or `.statusText` methods to only continue once the status is 4
Blauelf
@Blauelf
Sep 30 2015 15:40
@pratikr1593 speed and addUnit now only exist in the context of the constructor, while getSpeed is a property of the object, and therefore public.
ramireznoe01
@ramireznoe01
Sep 30 2015 15:41
please tell me what is wrong with my code. The error message says " undefined is not a function".
Isabelle Lepez
@Isabellle
Sep 30 2015 15:41
Oh ... let me have a closer look, but since it only returns 1 result it should only take less that a sec to do the get, let me check
ramireznoe01
@ramireznoe01
Sep 30 2015 15:41
This message was deleted
``````function unite(arr1, arr2, arr3) {

var flattened = unite.reduce(function(a, b) {
return a.concat(b);
});
return flattened;
}

unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);``````
Blauelf
@Blauelf
Sep 30 2015 15:43
@ramireznoe01 There is no unite.reduce. What you want is probably Array.prototype.slice.call(arguments).reduce()
Hugo
@hugoender
Sep 30 2015 15:44
@ramireznoe01 the `.reduce()` method is for Arrays and `unite` is a function
Herman Fassett
@HermanFassett
Sep 30 2015 15:44
@millinet you might want to do all your stuff inside the get function after you initialize the var so that you know it's done
Jonathan Lee Slew
@jlslew
Sep 30 2015 15:45
@millinet if you add a `console.log(fccDisplayName);` after line 19, you will see it is not undefined
ramireznoe01
@ramireznoe01
Sep 30 2015 15:45
oh i see
Isabelle Lepez
@Isabellle
Sep 30 2015 15:45
@hugoender @HermanFassett So statusText is 'OK' and status is 200 :-/ ... weird
let me check with the scope of that variable
Hugo
@hugoender
Sep 30 2015 15:46
@millinet well at least you know it's OK :) good to have that check in there anyways so you can handle instances when it's not OK
@millinet especially when dealing with the uncertainty of the INTERWEBZ!!
Hanni Abu
@HanniAbu
Sep 30 2015 15:59
@MattYamamoto Yes I did, thanks
CamperBot
@camperbot
Sep 30 2015 15:59
hanniabu sends brownie points to @mattyamamoto :sparkles: :thumbsup: :sparkles:
:star: 346 | @mattyamamoto | http://www.freecodecamp.com/mattyamamoto
jdreiser1
@jdreiser1
Sep 30 2015 16:08

function palindrome(str) {
// Good luck
str.replace(".", "");
str.replace(",", "");
res2.toLowerCase();
var array = res2.split("");
for (i=0; i < (array.length - 1); i++){
if (array[i] != array[(array.length-1)-i]){
return false;
}
return true;
}
}

palindrome(".eye.");

Trouble with Bonfire: Checking for Palindromes. Any help?
Hanni Abu
@HanniAbu
Sep 30 2015 16:08
where are you stuck
jdreiser1
@jdreiser1
Sep 30 2015 16:09
I can't seem to get remove the punctuation with my replace function.
Hanni Abu
@HanniAbu
Sep 30 2015 16:10
It's a lot easier/more concise to use regex
str = str.replace(/\s|.|\,|-|_|\?|)|(/g,"");
you place "|" between each character you would like to filter
Shouvik Roy
@royshouvik
Sep 30 2015 16:11
Hello campers
Anyone knows about open source angularjs projects other than FCC ??
Hanni Abu
@HanniAbu
Sep 30 2015 16:12
so this is removing spaces, periods, parenthesis, underscores, dashes, question marks, and commas
@royshouvik you mean for learning?
or just projects in general
Shouvik Roy
@royshouvik
Sep 30 2015 16:13
I am thinking about contributing to the projects @HanniAbu , this would help me in learning too
jdreiser1
@jdreiser1
Sep 30 2015 16:14
thanks @HanniAbu
CamperBot
@camperbot
Sep 30 2015 16:14
jdreiser1 sends brownie points to @hanniabu :sparkles: :thumbsup: :sparkles:
:star: 189 | @hanniabu | http://www.freecodecamp.com/hanniabu
Babs Craig
@babzcraig
Sep 30 2015 16:14
Any help for Chunky Monkey problem? Been on it for two days now.
Would appreciate some help with it.
Oliver
Sep 30 2015 16:15
What are unix users using to pair program?
Hanni Abu
@HanniAbu
Sep 30 2015 16:17
@royshouvik github posts lists periodically to stimulate the open source community
https://github.com/angular/angular.js/wiki/Projects-using-AngularJS
Avil
@Avil172
Sep 30 2015 16:17

can someone help me in understanding the output of this program?

``````understand=true;
while(understand)
{
console.log("while loop");
understand=false;
}``````

the output is..

``````while loop
false``````

i understand the first output is a result of the console.log("while loop"), but what gives the "false"?

Hanni Abu
@HanniAbu
Sep 30 2015 16:18
@Avil172 you are setting it to false
so to explain further.....
the while loop is saying that while understand=true(which it does, you set it to true), it will execute the code inside
the code inside is the console.log and changing the value of understand to false
now that understand does not equal true anymore, the while loop is exited
hope that helps
Oliver
Sep 30 2015 16:20
I think Avil's question is why False is returned
Hanni Abu
@HanniAbu
Sep 30 2015 16:20
oooooooo
i can't duplicate that result
Hugo
@hugoender
Sep 30 2015 16:21
@Avil172 you must be omitting something the the code you pasted
Hanni Abu
@HanniAbu
Sep 30 2015 16:21
is that all of the code @Avil172 ?
Shouvik Roy
@royshouvik
Sep 30 2015 16:23
Thanks @HanniAbu
CamperBot
@camperbot
Sep 30 2015 16:23
royshouvik sends brownie points to @hanniabu :sparkles: :thumbsup: :sparkles:
:star: 190 | @hanniabu | http://www.freecodecamp.com/hanniabu
Oliver
Sep 30 2015 16:27
@Avil172 I believe the reason for this "false" is that all functions in JS need to return something. When we set `understand=false` the while expression now evaluates to false so that is returned.
Hugo
@hugoender
Sep 30 2015 16:31
@Dadsaster am I missing something? I don't think there's a function in @Avil172 's code
oh wait
while() is a function
but do javascript functions really need to return something?
cuz then for(), while(), if() should all return something and i don't think thats the case
Oliver
Sep 30 2015 16:34
@hugoender - they don't have to explicitly return something but behind the scenes they return undefined so the interpreter knows the code block has completed
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:34

Hey gang, I'm stuck on this code that should return the largest number in the array, any suggestions? This is what I have so far:
function largestOfFour(arr) {
var num = 0;
for (i = 0; i<arr.length; i++) {
if (num < arr[i]) {
num = arr[i];
}

}
return num;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], "");

Oliver
Sep 30 2015 16:35
This message was deleted
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:35
It keeps returning 0
Hugo
@hugoender
Sep 30 2015 16:36
@ScottMillerWesCoas the argument you are passting to thefunction largestOfFour is not a 1 dimensional array
so its comparing a digit (number) to a 1 dimensional array (4,5,1,3) for arr[0]
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:37
oh, so it's apples and oranges, then? How do I adjust it so the code can handle a multi-dimensional array?
Hugo
@hugoender
Sep 30 2015 16:37
split the array
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:37
ohhhhh! Great idea!
Hugo
@hugoender
Sep 30 2015 16:37
i mean there are a few ways
but thats one
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:37
thanks, @hugoender !
CamperBot
@camperbot
Sep 30 2015 16:37
scottmillerwescoas sends brownie points to @hugoender :sparkles: :thumbsup: :sparkles:
:star: 200 | @hugoender | http://www.freecodecamp.com/hugoender
Hugo
@hugoender
Sep 30 2015 16:38
yay 200!
tva10
@tva10
Sep 30 2015 16:38
@ScottMillerWesCoas `arr[0][0]` -->4
Hugo
@hugoender
Sep 30 2015 16:38
@tva10 that works too
tva10
@tva10
Sep 30 2015 16:39
@ScottMillerWesCoas so if you use `arr[0]` you get an array `[4, 5, 1, 3]`
Hugo
@hugoender
Sep 30 2015 16:42
is it wrong that i sometimes enjoy the FCC chatrooms more than i do the waypoints and challenges?
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:42
no
Hugo
@hugoender
Sep 30 2015 16:42
@ScottMillerWesCoas you would say that lol
tva10
@tva10
Sep 30 2015 16:43
@hugoender may be normal
@hugoender I done most bonfires in first three days
@hugoender now I seat here.
Hugo
@hugoender
Sep 30 2015 16:44
"learning to code should be social" -Dont remember who
truer words were never spoken
Avil
@Avil172
Sep 30 2015 16:44
so it happens with if/else and for too(i mean the behind the scene "return")?
CamperBot
@camperbot
Sep 30 2015 16:44
avil172 sends brownie points to @hugoender and @dadsaster and @hanniabu :sparkles: :thumbsup: :sparkles:
:star: 191 | @hanniabu | http://www.freecodecamp.com/hanniabu
:star: 201 | @hugoender | http://www.freecodecamp.com/hugoender
Hugo
@hugoender
Sep 30 2015 16:45
@Avil172 so what @Dadsaster suggested was the issue? It was returning false?
cuz if that's the case then ive learned something new and i need to be aware of this while i code
@Avil172 what happens if you set `understand = 'testing'`? does it return `testing`
?
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:47

shoot, so I tried to split the array with the following code and it's saying arr.split is not a function - does the "split" function not work the same on arrays as on strings? Here's my code:

function largestOfFour(arr) {
var array = arr.split('');
var num = 0;
for (i = 0; i<array.length; i++) {
if (num < array[i]) {
num = array[i];
}

}
return num;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], "");

Avil
@Avil172
Sep 30 2015 16:47
@hugoender yep, i knew that console.log() is used to print, but i couldn't understand why it returned false.
@hugoender let me check
tva10
@tva10
Sep 30 2015 16:47
@ScottMillerWesCoas use loop in loop. It is more simple to mean
Avil
@Avil172
Sep 30 2015 16:48
@hugoender no it returned false too.
@hugoender wait, you meant understand inside while or understand above while?
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:49
I'm not sure what you mean, @tva10
Hugo
@hugoender
Sep 30 2015 16:49
@ScottMillerWesCoas oops i misinformed you... split is a String method not an array method
tva10
@tva10
Sep 30 2015 16:49
``````var arr=[[1,2][2,3]];
for(var i=0;i<arr.length;i++){
for(var j=0;j<arr[i].length;j++){
arr[i][j]=......;
}
}``````
Hugo
@hugoender
Sep 30 2015 16:49
@ScottMillerWesCoas do as @tva10 suggests....its cleaner
@SaintPeter
Sep 30 2015 16:49
@ScottMillerWesCoas The reason you use split on a string it to turn it into an array. This is already an array. Just loop through it, like @tva10 shows
Hugo
@hugoender
Sep 30 2015 16:50
@Avil172 inside the while loop
Scott Miller
@ScottMillerWesCoas
Sep 30 2015 16:50
and I'm doing a loop in another loop because it's a multi-dimensional array?
tva10
@tva10
Sep 30 2015 16:50
yes
hugoender @hugoender stares down @SaintPeter
tva10
@tva10
Sep 30 2015 16:50
one loop for every dimension
Srdjan1
@Srdjan1
Sep 30 2015 16:50

lastNameLength = 0;

firstNameLength = firstName.length;

var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName;

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
// You'll learn about functions soon.
if(typeof(lastNameLength) !== "undefined"){(function(){return lastNameLength;})();}var firstNameLength = 0;
var

how?
SaintPeter @SaintPeter laughs
@SaintPeter
Sep 30 2015 16:51
@hugoender I need to do work today anyway
Hugo
@hugoender
Sep 30 2015 16:51
@SaintPeter its fine...i hit 200 brownie points already :)
@Avril172 so it returns false when you set understand='test'; in the while loops?
@SaintPeter
Sep 30 2015 16:52
CamperBot
@camperbot
Sep 30 2015 16:52
:star: 795 | @saintpeter | http://www.freecodecamp.com/saintpeter
Hugo
@hugoender
Sep 30 2015 16:52
CamperBot
@camperbot
Sep 30 2015 16:52
:star: 201 | @hugoender | http://www.freecodecamp.com/hugoender
Avil
@Avil172
Sep 30 2015 16:52
@hugoender setting understand to "testing" above while loop caused it to return "false"(alongwith whatever it was inside console.log)
but when i set it inside understand, it caused browser crash(infinite loop), for some reason
@SaintPeter
Sep 30 2015 16:52
Thanks @hugoender for your dedication to helping people!
CamperBot
@camperbot
Sep 30 2015 16:52
saintpeter sends brownie points to @hugoender :sparkles: :thumbsup: :sparkles:
:star: 202 | @hugoender | http://www.freecodecamp.com/hugoender
Hugo
@hugoender
Sep 30 2015 16:52
@Avil172 LOL
Avil
@Avil172
Sep 30 2015 16:53
@hugoender idk
it wasn't supposed to be like that.
Hugo
@hugoender
Sep 30 2015 16:53
@Avil172 interesting... I choose @SaintPeter!
/me throws pocke-ball and @SaintPeter shoots out
Ben Heavner
@bheavner
Sep 30 2015 16:53
thx @blauelf - that's a really nice solution! I particularly like the conditional syntax you use in defining gcd, and the def of the a and b vars... Thanks for showing me that! You're the second person to tell me they'd use reduce - so it does seem like there's a reduce solution as well, though I don't understand it yet. I'll find it someday!
CamperBot
@camperbot
Sep 30 2015 16:53
bheavner sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 324 | @blauelf | http://www.freecodecamp.com/blauelf
Srdjan1
@Srdjan1
Sep 30 2015 16:53
..
hugoender @hugoender throws pocker-ball and @SaintPeter shoots out to help @Avil172 understand weird behavior
Hugo
@hugoender
Sep 30 2015 16:54
pocke-ball*
poke-ball**
Aayush Kapoor
@xeoneux
Sep 30 2015 16:54
@Srdjan1 Use `.length` property of String to get it's length like this
``lastNameLength = lastName.length;``
@SaintPeter
Sep 30 2015 16:54
Hugo
@hugoender
Sep 30 2015 16:56
@Avil172 try and change the first line to `var understand=true;`
Srdjan1
@Srdjan1
Sep 30 2015 16:56
tnx @xeoneux
CamperBot
@camperbot
Sep 30 2015 16:56
srdjan1 sends brownie points to @xeoneux :sparkles: :thumbsup: :sparkles:
:star: 267 | @xeoneux | http://www.freecodecamp.com/xeoneux
Hugo
@hugoender
Sep 30 2015 16:56
@Avil172 so add `var`
i wish i was on my computer so i could test your code out
alas i am on my ipad so functionality is limited
Avil
@Avil172
Sep 30 2015 16:57
Jason Wood
@catapixel
Sep 30 2015 16:58
Anyone willing to offer some help on Waypoint: Start a Nodejs Server?
Hugo
@hugoender
Sep 30 2015 16:58
@Avil172 okay so where are you running this code? in the FCC text editor or some other place (like repl.it)? and have you copied ALL of your code?
into this chat?
Avil
@Avil172
Sep 30 2015 16:58
i accidentally posted understand=testing inside while loop, whereas i should have posted "==="
Hugo
@hugoender
Sep 30 2015 16:58
AHHHH
@Avil172 wait no...
@Avil172 you need to put `understand = 'testing';`
not `===`
`===` is used to compare
`=` is used to assign a value
Avil
@Avil172
Sep 30 2015 17:01

@hugoender

``````var understand = true;

while( understand==="testing" ){
console.log("I'm learning while loops!");
understand = false;
}``````

^ doesn't have any output, but this..

``````var understand = true;

while( understand=true ){
console.log("I'm learning while loops!");
understand = false;
}``````

is causing crash(infinite loop)

this..

``````var understand = true;

while( understand ){
console.log("I'm learning while loops!");
understand = false;
}``````

has an output..

``````I'm learning while loops!
false``````
Jonathan Lee Slew
@jlslew
Sep 30 2015 17:01
@catapixel sure, what do you have so far?
duan walker
@duanwalker
Sep 30 2015 17:03
just to let you guys know...im now solving BFs without you guys help and im super proud of myself! ok carry on
Oliver
Sep 30 2015 17:04
@Avil172 `while(false){console.log('foo');}` should return undefined - this is the same as the first example you posted above `while (understand === 'testing')`
Jason Wood
@catapixel
Sep 30 2015 17:04

@jlslew the problem is with the I/O part. My code is returning a much different value than they say it should when I run it against their file. I have this as my code:

``````var fs = require('fs');
console.log(counterArray.length - 1);``````

Answer according to "verify" is 46 but my answer is much higher...

Aayush Kapoor
@xeoneux
Sep 30 2015 17:05
@catapixel Shouldn't it be `.split("\n");`?
Jonathan Lee Slew
@jlslew
Sep 30 2015 17:05
@catapixel you need to specify the encoding
currently returning a buffer, but with encoding of utf-8, return a string
Jason Wood
@catapixel
Sep 30 2015 17:06
@xeoneux it's supposed to split on newline so the regex should be correct I think
Aayush Kapoor
@xeoneux
Sep 30 2015 17:06
@catapixel Oh... Got it
Jason Wood
@catapixel
Sep 30 2015 17:06
@jlslew according to the doc it defaults to UTF8 if encoding is not specified
Avil
@Avil172
Sep 30 2015 17:06
@Dadsaster you mean `while(understand=false){console.log('foo');}`
right?
Jonathan Lee Slew
@jlslew
Sep 30 2015 17:07
Oliver
Sep 30 2015 17:08
@Avil172 no - I was trying to show that when the while loop is never entered it returns `undefined` - if it is entered and then the conditional statement evaluates to false it returns `false`
Jason Wood
@catapixel
Sep 30 2015 17:08
@jlslew if I feed it the README.md file it returns an exact copy once I make it a string. If I read theirs then I get something too big to open
Avil
@Avil172
Sep 30 2015 17:09
Jonathan Lee Slew
@jlslew
Sep 30 2015 17:09
@catapixel when i run `console.log(fs.readFileSync(process.argv[2]));` I get `<Buffer 57 65 27 72 65 20 67 6f 69 6e 67 20 64 69 6c 6c 20 77 69 74 68 20 69 74 27 6c 6c 20 62 65 20 72 69 64 67 79 2d 64 69 64 67 65 2e 20 41 73 20 62 75 73 79 ...>`
Oliver
Sep 30 2015 17:10

@Avil172

``````var understand = true;

while( understand==="testing" ){
console.log("I'm learning while loops!");
understand = false;
}``````

This example you posted returns undefined because the loop is never entered

Avil
@Avil172
Sep 30 2015 17:10
@Dadsaster well, when i said no output, i meant that there was some error so it didn't show me any output
Jason Wood
@catapixel
Sep 30 2015 17:10
@jlslew I was using argv0 and not argv2. I assumed zero since I was forgetting 0 was 'node' and '1' was the filepath. Thanks!
CamperBot
@camperbot
Sep 30 2015 17:10
catapixel sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 252 | @jlslew | http://www.freecodecamp.com/jlslew
Avil
@Avil172
Sep 30 2015 17:12
@Dadsaster yeah, i understand. the "while" condition was never met, so it won't even enter the loop. and then, outside the loop, there is nothing to print.
Oliver
Sep 30 2015 17:12
@Avil172 - cool!
Avil
@Avil172
Sep 30 2015 17:19

@Dadsaster btw, can you(or anyone else) explain this to me(another topic)

``````var arr=[];
console.log(arr.push("test"));
console.log(arr);``````

output:

``````1
test``````

well, i am trying to understand the push command here. i know that it inserts element into the array. but why did it print 1? 1 is arr.length, isn't it?
my second question is, i never performed the operation (look at the second line, input part)separately, ie `arr.push("test");` but instead, i wrote `console.log(arr.push("test"));` which is used to show the output.
so how was the operation performed inside console.log? is it even possible?

Oliver
Sep 30 2015 17:21
The push() method adds one or more elements to the end of an array and returns the new length of the array.
Aayush Kapoor
@xeoneux
Sep 30 2015 17:21
@Avil172 Every function in JS returns something
@Avil172 Here, the Array.push() method returns the new length of the Array
Luis Felipe López G.
@luishendrix92
Sep 30 2015 17:21
@Avil172 console.log outputs the length of the array, that's the returned value, the length of this which is the array in which .push() was called upon.
Aayush Kapoor
@xeoneux
Sep 30 2015 17:21
@Avil172 Check the official documentation here
Avil
@Avil172
Sep 30 2015 17:24
CamperBot
@camperbot
Sep 30 2015 17:24
avil172 sends brownie points to @dadsaster and @xeoneux and @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star: 268 | @xeoneux | http://www.freecodecamp.com/xeoneux
:star: 388 | @luishendrix92 | http://www.freecodecamp.com/luishendrix92
Oliver
Sep 30 2015 17:24
@Avil172 as for your second question - whatever you place inside a `console.log` statement will be evaluated before it is printed. Since the push method returns the length that is what it is evaluated to. This a common way to debug a program
Avil
@Avil172
Sep 30 2015 17:26
Sara Hall
@sarahall
Sep 30 2015 17:33
Hi everyone! I'm very new to Free Code Camp but not unfamilar with HTML & CSS. Should I (and do I need to) complete all of the HTML/CSS Waypoints before I proceed to the next waypoints?
Jonathan Coleman
@jondcoleman
Sep 30 2015 17:35
HI @sarahall I skipped all of the HTML & CSS and went straight to js
You can still get the certificates without completing the waypoints
just make sure you are comfortable with the material because it will be important for the bonfires and ziplines
Jordan Bourne
@JordanBourne
Sep 30 2015 17:37
I'm having some issues with the setInterval() and clearInterval() functions, could someone here help me?
Oliver
Sep 30 2015 17:39
@JordanBourne can you post code?
Jordan Bourne
@JordanBourne
Sep 30 2015 17:39
I have it in a codepen here: http://codepen.io/JBourne/pen/JYEKrd
I can just link the js code if you want though
Sara Hall
@sarahall
Sep 30 2015 17:41
@jondcoleman Thanks, I figured that would be okay, didn't want it to bite me in the rear later.
CamperBot
@camperbot
Sep 30 2015 17:41
sarahall sends brownie points to @jondcoleman :sparkles: :thumbsup: :sparkles:
:star: 93 | @jondcoleman | http://www.freecodecamp.com/jondcoleman
Jordan Bourne
@JordanBourne
Sep 30 2015 17:42
Right now, after pressing the Start button it's supposed to turn into a reset button (working), and the reset button should reset the time (working) but also stop the countdown (not working)
Jonathan Lee Slew
@jlslew
Sep 30 2015 17:44
@JordanBourne you need to make myVar global, ie, move it at top of file
Hugo
@hugoender
Sep 30 2015 17:45
@Avil172 sorry i was afk (had to drive somewhere). I meant to set understand='testing' INSIDE the while loop.
@Avil172 i am sure you have moved on by now so nevermind :)
Jordan Bourne
@JordanBourne
Sep 30 2015 17:46
@jlslew do I just cutpaste the whole setInterval with it as well? How do I call it later when I click?
Jonathan Lee Slew
@jlslew
Sep 30 2015 17:47
@JordanBourne at top of file: var myVar = null;
and remove var at line 29
Jordan Bourne
@JordanBourne
Sep 30 2015 17:48
thanks @jlslew I got it working
CamperBot
@camperbot
Sep 30 2015 17:48
jordanbourne sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 253 | @jlslew | http://www.freecodecamp.com/jlslew
tmitrache
@tmitrache
Sep 30 2015 17:56
If i make a json request that utilises an IP through the JS section on codepen will it use the website visitor's Ip address?
tva10
@tva10
Sep 30 2015 17:58
@tmitrache it use web browser to send request
@tmitrache so Ip should be from visitor
tmitrache
@tmitrache
Sep 30 2015 18:00
@tva10 thanks
CamperBot
@camperbot
Sep 30 2015 18:00
tmitrache sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:star: 269 | @tva10 | http://www.freecodecamp.com/tva10
Peter Daily
@thepeted
Sep 30 2015 18:09
Good evening!
Mizzix
@Mizzix
Sep 30 2015 18:10
good afternoon, @thepeted :)
Peter Daily
@thepeted
Sep 30 2015 18:10
Any AJAX experts out there could help me with the twitch API? I can get the JSON fine. While I’m prob going over the top, I’m intrigued about how to set the correct version as described in the API docs https://github.com/justintv/Twitch-API especially the bit about "Responses will have an x-api-version header that will indicate which version you received."
I’m playing about with jquery.ajax here: http://codepen.io/thepeted/pen/GprQGJ
PersonUvInterest0709
@PersonUvInterest0709
Sep 30 2015 18:11
@thepeted hey how do i nest a form action in an element?
Peter Daily
@thepeted
Sep 30 2015 18:11
@PersonUvInterest0709 I’m not sure I understand the question - could you give an example?
How do you get that header - closest I’ve come is this, but it doesn’t include version info ```\$.ajax({ 'url': 'https://api.twitch.tv/kraken/streams/freecodecamp?api_version=3', 'success': function(results, string, jqXHR){ console.log(jqXHR.getAllResponseHeaders()) } });```
Jonathan Lee Slew
@jlslew
Sep 30 2015 18:15
@thepeted try this
``````\$.getJSON("https://api.twitch.tv/kraken/streams/medrybw", function(result){
console.log(result.stream);
});``````
@thepeted why do you need the header?
PersonUvInterest0709
@PersonUvInterest0709
Sep 30 2015 18:17
@thepeted <form action="/url-where-you-want-to-submit-form-data"></form>. how do i nest the text field within this element?
Peter Daily
@thepeted
Sep 30 2015 18:18
@jlslew I know how to get the JSON OK, but I’d like to get the header info to confirm that I have succesfully requested the correct version, as described in the API docs here: https://github.com/justintv/Twitch-API#api-versions-and-mime-types
Jonathan Lee Slew
@jlslew
Sep 30 2015 18:18
@PersonUvInterest0709
``````<form action="">
<input type="text" />
</form>``````
Peter Daily
@thepeted
Sep 30 2015 18:19
I know its prob overkill for this project, but I’m intr