These are chat archives for FreeCodeCamp/Help

23rd
Sep 2015
Mateja Trifunovski
@Matko95
Sep 23 2015 00:00
@aaronmarkle you need to write pink-text first, then blue-text
in your class
@JelaniThompson try to use display: inline-block more often instead of float
@JelaniThompson and target the parent id and add text-align: center;
Michael Green
@MichaelGreenNZ
Sep 23 2015 00:02
var Car = function() {
   this.wheels = 4;
};

// Only change code below this line.
var myCar = new Car();

//Add the property "engines" to myCar, and make it a number.
myCar.engines = 1;

// Only change code above this line.
(function() {return JSON.stringify(myCar);})();

How do we get to this, specifically

myCar.engines = 1;

When it isn’t mentioned in the description?

or in the previous waypoints, we haven’t used this particular constructor like this?
Mateja Trifunovski
@Matko95
Sep 23 2015 00:03
@MichaelGreenNZ how did you get to it?
Michael Green
@MichaelGreenNZ
Sep 23 2015 00:04

@Matko95 searched google for "Waypoint Make Instances of Objects with a Constructor Function help” and it went to the github page about this which shows the correct solution.

https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Waypoint-Make-Instances-of-Objects-with-a-Constructor-Function

or, what the waypoint was looking for.
Mateja Trifunovski
@Matko95
Sep 23 2015 00:05
@MichaelGreenNZ If it's too fast for you i would recommend you to take the course on codecademy for javascript
@MichaelGreenNZ it will help you pick up the basics
Hugo
@hugoender
Sep 23 2015 00:08
@MichaelGreenNZ get used to this. As you move forward in the way points they explain less and less.
OverTheNeptune
@OverTheNeptune
Sep 23 2015 00:09
@fractal-mind The function declared inside your convert() function is defining a parameter also named 'num'. It isn't actually receiving the value passed to your convert() function. You'd need to pass the 'num' argument from convert() to your function().

function convert(num) {

 (function(num)
   {
     console.log(num); 
   }

 )(num);
}

convert(36);
@fractal-mind Code below may make it a little clearer.

function convert(num1) {

 (function(num2)
   {
     console.log(num2); 
   }

 )(num1);
}

convert(36);
Michael Green
@MichaelGreenNZ
Sep 23 2015 00:11

@hugoender Yup, Explain less and less fine. But I don’t remember using something like

myCar.engines = 1;

anywhere else. Not specifically that use or a form of it.

thanks for the suggestsions @hugoender and @Matko95.

I’ll go take a look at codecademy course, and keep my google-fu up to scratch for other waypoints.

CamperBot
@camperbot
Sep 23 2015 00:13
michaelgreennz sends brownie points to @hugoender and @matko95 :sparkles: :thumbsup: :sparkles:
:star: 176 | @hugoender | http://www.freecodecamp.com/hugoender
:star: 350 | @matko95 | http://www.freecodecamp.com/matko95
Michael Bomholt
@bomholtm
Sep 23 2015 00:16
is there a way to set the z-index of a box shadow to another number then the element it surrounds? basically i want two overlapping divs with a box shadow only on the outline around them ... not inside of the div where they overlap
Will Moody
@willmoody
Sep 23 2015 00:22
@OverTheNeptune Thanks so much! I see what you mean.
CamperBot
@camperbot
Sep 23 2015 00:22
fractal-mind sends brownie points to @overtheneptune :sparkles: :thumbsup: :sparkles:
:star: 201 | @overtheneptune | http://www.freecodecamp.com/overtheneptune
Brian Hogue
@syzygy333
Sep 23 2015 00:23
hey all. i started FCC last week and have run into a wall on one of the bonfires. i recognize the following code is probably not the best way to approach the problem, but realize this is only my most recent attempt. can anyone give me a shove in the right direction? when i run it, it doesn't capitalize anything, although if i do something like console.log(array[0].toUpperCase()), it works as i imagine. i appreciate any help:
function titleCase(str) {
  array = str.toLowerCase().split("");
  for(var i = 0; i < array.length; i++) {
    if(i == 0) {
      array[i].toUpperCase();
    } else if (array[i] == " ") {
      array[i + 1].toUpperCase();
    }
  }
  return array;
}

titleCase("I'm a little tea pot", "");
OverTheNeptune
@OverTheNeptune
Sep 23 2015 00:28
@fractal-mind No problem. Glad I could help!
akmalist
@akmalist
Sep 23 2015 00:30

<style>
.red-text {color: red;
}
h1 {font-size:16px; }


</style>

<h2 class="red-texth">CatPhotoApp</h2>

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class ="red-text">kitty ipsum text: Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Give your p elements the font-size of 16px
cant get it
azazel913
@azazel913
Sep 23 2015 00:30
@Matko95 did what you said still not making it blue
akmalist
@akmalist
Sep 23 2015 00:30
could you guys help me
Mateja Trifunovski
@Matko95
Sep 23 2015 00:31
@azazel913
<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
  }
  .pink-text {
    color: pink;
  }
  .blue-text{
    color: blue;
  }
</style>
<h1 class="pink-text blue-text">Hello World!</h1>
@akmalist in your style you have put h1 {font-size: 16px;} and it should target the p element
and your class in h2 is wrong, it should be red-text, and it's red-texth @akmalist
azazel913
@azazel913
Sep 23 2015 00:34
@matko95 that's is how I have it right now but it won't turn blue
akmalist
@akmalist
Sep 23 2015 00:35
@Matko95 I did but its not working
Mateja Trifunovski
@Matko95
Sep 23 2015 00:35
@azazel913 try a different browser then maybe
@akmalist you did what?
akmalist
@akmalist
Sep 23 2015 00:38

@Matko95
<style h1 {font-size:16px; }>
.red-text {color: red;
}

</style>

Mateja Trifunovski
@Matko95
Sep 23 2015 00:38
@akmalist not like that...
<style>
.red-text{
color: red;
}
p{
font-size: 16px;
}

</style>
Michael Green
@MichaelGreenNZ
Sep 23 2015 00:38
@akmalist
in your code your targeting the h1… not the p element like the exercise asks you to.
akmalist
@akmalist
Sep 23 2015 00:40
@MichaelGreenNZ @Matko95 Merci !!!!!
azazel913
@azazel913
Sep 23 2015 00:41
I figured it out
Solms Dykman
@solms
Sep 23 2015 01:02
Hi guys! This is my first time asking for help here, but I am oh so stuck. I am busy with the "Show your local weather" zipline, and I just cannot get the OpenWeatherMap API to respond as I expect. Please bear in mind that I'm still very confused about all aspects of web dev, but JSON and $.getJSON(...) really has me lost.

Oh shoot, the problem:
why does this not do anything?

var api_URL = "api.openweathermap.org/data/2.5/weather?lat="; + geo_location.lat + "&lon=" + geo_location.lng + "&APPID=" + api_key;
console.log("API URL: " + api_URL);
// Attempt to retrieve the weather info JSON from OWM
$.getJSON(api_URL, null, function(result){
console.log("Hello");
});

The geo_location has values, and if I copy and past the string generated for api_URL, and put it in my browser, I get all the info I wanted. Where is my mistake?

Hans van Riet
@hansinla
Sep 23 2015 01:05
@Stykes You have a semicolon ; after lat=
Solms Dykman
@solms
Sep 23 2015 01:05
@hansinla WOW.
:/
Thank you!
CamperBot
@camperbot
Sep 23 2015 01:05
if you want to thank someone, put an @ before their name!
Solms Dykman
@solms
Sep 23 2015 01:09
@hansinla Yup - that solved the problem. No idea how I missed it. Thank you so much!
CamperBot
@camperbot
Sep 23 2015 01:09
stykes sends brownie points to @hansinla :sparkles: :thumbsup: :sparkles:
:star: 389 | @hansinla | http://www.freecodecamp.com/hansinla
Hans van Riet
@hansinla
Sep 23 2015 01:09
@Stykes No problem
flicktron
@flicktron
Sep 23 2015 01:16
Hey guys, first time here. I was working on Modifying Data Arrays. I submitted my code to be ourArray[0] = 3; and it came out wrong. It's almost identical to example above it. Anyone know what I might be doing wrong?
Bill
@kirah1314
Sep 23 2015 01:17
@flicktron can you paste your codes so we can help debug it?
mcrocco06
@mcrocco06
Sep 23 2015 01:18
ourArray is the example, myArray is yours
flicktron
@flicktron
Sep 23 2015 01:20
How would I post the code?
Bill
@kirah1314
Sep 23 2015 01:20
@flicktron copy/paste your part of the codes in this chat area
flicktron
@flicktron
Sep 23 2015 01:20
That worked! Thank you @mcrocco06
CamperBot
@camperbot
Sep 23 2015 01:20
flicktron sends brownie points to @mcrocco06 :sparkles: :thumbsup: :sparkles:
:star: 161 | @mcrocco06 | http://www.freecodecamp.com/mcrocco06
Bill
@kirah1314
Sep 23 2015 01:21
or just solve it :)
flicktron
@flicktron
Sep 23 2015 01:21
I had posted the ourArray[0] = 3;, didn't know if there was a way to frame it. But thank you for helping.
CamperBot
@camperbot
Sep 23 2015 01:21
if you want to thank someone, put an @ before their name!
Michael Green
@MichaelGreenNZ
Sep 23 2015 01:22
This message was deleted
This message was deleted
This message was deleted
flicktron
@flicktron
Sep 23 2015 01:24
hmm, how would I do that
Michael Green
@MichaelGreenNZ
Sep 23 2015 01:24
bob the bot, doesn’t want to play ball..
CamperBot
@camperbot
Sep 23 2015 01:24
this is bob @dcsan
Michael Green
@MichaelGreenNZ
Sep 23 2015 01:26
@flicktron https://github.com/freecodecamp/freecodecamp/wiki/code-formatting well this is what I was trying to get bob to tell us.. here’s the link anyway!
DJ
@qualitymanifest
Sep 23 2015 01:41
help format
CamperBot
@camperbot
Sep 23 2015 01:41

: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

```js ⇦ Type 3 backticks, then type js or html 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

:pencil: read more about code formatting on the FCC Wiki

Chris
@Shifthawke
Sep 23 2015 02:05
BOB
CamperBot
@camperbot
Sep 23 2015 02:05
this is bob @dcsan
Danny
@ShiLi007
Sep 23 2015 02:10

function palindrome(str) {
// Good luck!

str=str.replace(/[\s]+/g,"");

return str==str.split("").reverse().join("");

}

palindrome("eye");

how do i to lowercase -~.~
DJ
@qualitymanifest
Sep 23 2015 02:12
str = str.toLowerCase();
Danny
@ShiLi007
Sep 23 2015 02:13
after replace? str=str.replace(/[\s]+/g,"").toLowerCase
DJ
@qualitymanifest
Sep 23 2015 02:16
yes but don't forget the parentheses
DTing
@dting
Sep 23 2015 02:24
@ShiLi007 you also need to get rid of the punctuations
not just spaces
Wiko
@wico216
Sep 23 2015 02:26

'''.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image" class="thick-green-border" src="https://bit.ly/fcc-relaxing-cat">'''

CamperBot
@camperbot
Sep 23 2015 02:26
:bulb: to format code use backticks! ``` more info
Wiko
@wico216
Sep 23 2015 02:27
'''
CamperBot
@camperbot
Sep 23 2015 02:27
:bulb: to format code use backticks! ``` more info
Wiko
@wico216
Sep 23 2015 02:27

'''
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image" class="thick-green-border" src="https://bit.ly/fcc-relaxing-cat">
'''

CamperBot
@camperbot
Sep 23 2015 02:27
:bulb: to format code use backticks! ``` more info
DJ
@qualitymanifest
Sep 23 2015 02:28
` is a backtick. ' is a single quote
backticks are usually upper left of the keyboard
Wiko
@wico216
Sep 23 2015 02:28
thanks @qualitymanifest
CamperBot
@camperbot
Sep 23 2015 02:28
wico216 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 221 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Sep 23 2015 02:28
no problem. so what are you trying to do?
Wiko
@wico216
Sep 23 2015 02:30
i'm on waypoint 19 and is not running, where did i go wrong?
.thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image" class="thick-green-border" src="https://bit.ly/fcc-relaxing-cat">
DTing
@dting
Sep 23 2015 02:30
@wico216 you have 2 class attributes for your img tag
you should have 1 class attributes with the classes separated by spaces
<img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat">
DJ
@qualitymanifest
Sep 23 2015 02:31
also you don't have an opening style tag
Wiko
@wico216
Sep 23 2015 02:32
thanks @dting, that was it :D
CamperBot
@camperbot
Sep 23 2015 02:32
wico216 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1231 | @dting | http://www.freecodecamp.com/dting
DJ
@qualitymanifest
Sep 23 2015 02:46
alright give me a moment i'm trying to find the fix
Phou
@nuttdguy
Sep 23 2015 02:47
@qualitymanifest , In the room. Now why is there test trying to pass "0" into factorize and it return "1"
@qualitymanifest .. Okay, sounds good!
DJ
@qualitymanifest
Sep 23 2015 02:47
it's not the test, it's your code
if you change how you initialize i in the beginning, it will pass.
thefacilitator
@thefacilitator
Sep 23 2015 02:48
Hey, I asked this a while back but logged out before getting an answer. Currently doing the Create a JavaScript Slot Machine waypoint, and am getting $ is not defined errors
slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1; slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1; slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
Zufrizal Yordan
@zufrizalyordan
Sep 23 2015 02:49
@thefacilitator have you included jQuery file?
DJ
@qualitymanifest
Sep 23 2015 02:49
@Nuttdguy i can give you the answer if you want
since you've already gotten 98% of it. but it might be better for you to figure it out on your own
Phou
@nuttdguy
Sep 23 2015 02:50
@qualitymanifest, yeah, I'd like to know. Have been on that "one" flame exercise for tooooo long .. lol
DJ
@qualitymanifest
Sep 23 2015 02:50
in the beginning, set i to 2, not 0. that way, your while loop doesn't end up trying to multiply by 0
which makes your final answer 0
Phou
@nuttdguy
Sep 23 2015 02:52
@qualitymanifest ... hmmm ... not sure why that would work???? Will definitely have to scratch my head on that one ... lol.
@qualitymanifest .. but THANKS! I don't think I would've have figured that one out.
CamperBot
@camperbot
Sep 23 2015 02:52
nuttdguy sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 222 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Sep 23 2015 02:53
@Nuttdguy your console.logs were a good idea, and they point out that it's the last two iterations of the loop that try to multiply by 0
basically, you just needed to end your loop sooner so that wouldn't happen
since anything x 0 = 0
thefacilitator
@thefacilitator
Sep 23 2015 02:54
@zufrizalyordan It's only asking for the random number code for the three slots. The rest is pre-filled
Phou
@nuttdguy
Sep 23 2015 02:54
@qualitymanifest ... it still failed their test. ;-(
@qualitymanifest ... this is where it fails :: assert(factorialize(0) === 1, '0 should return 1.');0 should return 1.
DJ
@qualitymanifest
Sep 23 2015 02:55
huh. give me a sec
Graham Whitley
@lotusgraham
Sep 23 2015 02:57
Screenshot 2015-09-22 at 10.51.18 PM.png
can i get some help on this? perhaps even some clarification on what i'm doing wrong/leaving out?
Phou
@nuttdguy
Sep 23 2015 02:58
@qualitymanifest ... It seems their test is trying pass a "0" value into factorialize function. Thereon (0*1) will always equal "0", no/yes?? I think the former.
DJ
@qualitymanifest
Sep 23 2015 02:58
@Nuttdguy yeah... i'm having trouble figuring out what they're trying to do there. because they want it to equal one, which doesn't make sense to me
@lotusgraham i think you need to assign reverse like arr = arr.reverse();
Phou
@nuttdguy
Sep 23 2015 03:00
@lotusgraham .. use console.log after each statement: then open your developer console and see the result for the variable each time. It will help you understand it.
Danny
@ShiLi007
Sep 23 2015 03:00
str = str.toLowerCase().replace(/\W/gi,""); assert(palindrome("0_0 (: /-\ :) 0-0") === true, '"0_0 (: /-\ :) 0-0" should return true.');"0_0 (: /-\ :) 0-0" should return true.
can't pass this one
Phou
@nuttdguy
Sep 23 2015 03:01
@qualitymanifest ... lol ... doesn't make sense to me either. But it it passes when recursion is used... strange.
DJ
@qualitymanifest
Sep 23 2015 03:02
@Nuttdguy yeah i don't get it. i found a ridiculous way to make it pass though. after the loop, insert this:
if (num == 0) {
  num = 1;
}
Phou
@nuttdguy
Sep 23 2015 03:02
@qualitymanifest ... what if an "||" was used in the while loop, would that work??
DJ
@qualitymanifest
Sep 23 2015 03:03
@Nuttdguy hmm idk i don't see how you could address the problem that way...
Phou
@nuttdguy
Sep 23 2015 03:03
@qualitymanifest .. nice, you found a way for it to pass! :-)
DJ
@qualitymanifest
Sep 23 2015 03:04
@Nuttdguy wait a minute, check this out
http://zero-factorial.com/whatis.html
navicyclical
@navicyclical
Sep 23 2015 03:04
I'm working on the factorialize a number bonfire and I get a unexpected token ) error, I think I might be stuck in curly brace hell...
function factorialize(num) {
  if (num == 0){
    return 1;
  }
   else{
     for (i=1, i=num, i++){
     num = (num * i);
    }
  };
  return num;
}

factorialize(5, '');
DJ
@qualitymanifest
Sep 23 2015 03:04
either way it passes but with a a bandaid
@navicyclical you're using commas in your for loop
DTing
@dting
Sep 23 2015 03:06
@navicyclical
for (var i=1; i=num; i++){ // dont use global i. also use ; as separators
Phou
@nuttdguy
Sep 23 2015 03:06
@qualitymanifest ... OH YEAH!! It has passed with your suggestion!! Thanks for the help!
CamperBot
@camperbot
Sep 23 2015 03:06
nuttdguy sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:warning: nuttdguy already gave qualitymanifest points
DJ
@qualitymanifest
Sep 23 2015 03:08
@navicyclical but if you fix that i think you just end up with an infinite loop, since you're changing num with each pass of the loop
navicyclical
@navicyclical
Sep 23 2015 03:08
@dting what should I used instead of global i?
DJ
@qualitymanifest
Sep 23 2015 03:08
var i = 1. not just i = 1
makes it local
navicyclical
@navicyclical
Sep 23 2015 03:08
and @qualitymanifest I'm getting an infinite loop
DTing
@dting
Sep 23 2015 03:08
function factorialize(num) {
  if (num == 0){
    return 1;
  }
  // else isnt needed since the if block returns.
  for (var i=1; i <= num; i++) { // done use global i, use var i. i <= num not assign i = num. use separators.
   num = (num * i);
  }
  return num;
}

factorialize(5, '');
DJ
@qualitymanifest
Sep 23 2015 03:09
@navicyclical yes, because you're increasing num each time, the loop never ends because i never reaches num
DTing
@dting
Sep 23 2015 03:09
ahh oops missed that point
Zufrizal Yordan
@zufrizalyordan
Sep 23 2015 03:09
@navicyclical and any others learning JS, please use ===`` instead of==``` for comparison. anybody wants to chip in why?
DTing
@dting
Sep 23 2015 03:09
need a var to store the result instead of assigning num in the loop ya
@zufrizalyordan === is strictly equals with no type-conversion
its not really a big deal in this case because the input values are all numbers
JeremyWBean
@JeremyWBean
Sep 23 2015 03:12
Alright, folks. I've worked my bottom off on Tic-Tac-Toe. I would appreciate it if you would all take a look and see if it is working for you. (Play ten times for a piece of extra functionality :) ) http://codepen.io/JeremyWBean/full/bVegdO/
DTing
@dting
Sep 23 2015 03:12
@JeremyWBean nice job
it's not supposed to be unbeatable right?
JeremyWBean
@JeremyWBean
Sep 23 2015 03:13
Crud... Did you beat it? :)
Zufrizal Yordan
@zufrizalyordan
Sep 23 2015 03:13
@dting +100. yes, but i think its better if people know the difference between === and == . this will save someone's time in the future. i've learnt the hard way. :)
DTing
@dting
Sep 23 2015 03:13
ya, 5, 9, 3, 7
@JeremyWBean 1-indexed, [5, 9, 3, 6]
JeremyWBean
@JeremyWBean
Sep 23 2015 03:14
Thank you! I think I can knock that out pretty quickly. I'll be back!
CamperBot
@camperbot
Sep 23 2015 03:14
if you want to thank someone, put an @ before their name!
Aaron Markle
@aaronmarkle
Sep 23 2015 03:14
after playing 10 times it gave me a message saying i enjoyed losing 10 times, even though i won at least 3 of those rounds!
JeremyWBean
@JeremyWBean
Sep 23 2015 03:14
@aaronmarkle I am going to fix that right now. Thanks
CamperBot
@camperbot
Sep 23 2015 03:14
jeremywbean sends brownie points to @aaronmarkle :sparkles: :thumbsup: :sparkles:
:star: 116 | @aaronmarkle | http://www.freecodecamp.com/aaronmarkle
OverTheNeptune
@OverTheNeptune
Sep 23 2015 03:16
@zufrizalyordan Seems like it would be a good habit to always use === except in cases where you deliberately needed to compare values that may be of differing types.
Aaron Markle
@aaronmarkle
Sep 23 2015 03:16
@JeremyWBean animations are smooth though, most peaceful game of tic tac toe i've ever played :+1:
Phou
@nuttdguy
Sep 23 2015 03:16
@JeremyWBean , pretty neat. It seems the code logic behind it determined rather than random. Is that so? Also, it's pretty amusing and looks good!
navicyclical
@navicyclical
Sep 23 2015 03:18
@dting i cleaned up the code and I get a illegal return statement
function factorialize(num) {
    if (num === 0){
    return 1;
  }
     for (var i=1; i<=num; i++){
     num = (num * i);
    }
  return num;
}

factorialize(5, '');
Zufrizal Yordan
@zufrizalyordan
Sep 23 2015 03:18
@OverTheNeptune i absolutely agree with you
DTing
@dting
Sep 23 2015 03:19
@navicyclical you need a variable to keep track of your answer instead of using num
JeremyWBean
@JeremyWBean
Sep 23 2015 03:19
@aaronmarkle Glad I could calm you. :)
@Nuttdguy It is determined. It is supposed to win every game, but i am having a problem right now. Thanks for checking it out.
CamperBot
@camperbot
Sep 23 2015 03:19
jeremywbean sends brownie points to @nuttdguy :sparkles: :thumbsup: :sparkles:
:star: 239 | @nuttdguy | http://www.freecodecamp.com/nuttdguy
Phou
@nuttdguy
Sep 23 2015 03:19
@JeremyWBean .. yup, I found the sweet winning spot in your game! Won every time .. YES!! I must say again, I really like how turned out!
DTing
@dting
Sep 23 2015 03:20
bf factorialize
CamperBot
@camperbot
Sep 23 2015 03:20

:fire:Bonfire: Factorialize a Number :link:

function factorialize(num) {
  return num;
}

factorialize(5);

Return the factorial of the provided integer.

more info:  bf details | bf links | hint

JeremyWBean
@JeremyWBean
Sep 23 2015 03:20
@Nuttdguy Thanks. What is the sweet spot you found so I can try and counteract it. :)
CamperBot
@camperbot
Sep 23 2015 03:20
jeremywbean sends brownie points to @nuttdguy :sparkles: :thumbsup: :sparkles:
:warning: jeremywbean already gave nuttdguy points
Hugo
@hugoender
Sep 23 2015 03:21

Can someone help me understand Regex real quick? I want to search a string for numbers and spaces. I have the following:

str.replace(/\d+\s+/,'');

Is this correct?

Phou
@nuttdguy
Sep 23 2015 03:21
@JeremyWBean .. let me find it again.
Rex Schrader
@SaintPeter
Sep 23 2015 03:23
@hugoender Almost. What you want is a character class:
/[\d\s]+/ or /[a-zA-Z0-9]/ - What you have above finds one or more digits followed by one or more spaces.
DTing
@dting
Sep 23 2015 03:23
@hugoender you need to use brackets or a | to indicate or. also use the global flag, g, if you want to replace all occurances
Hugo
@hugoender
Sep 23 2015 03:24
@SaintPeter @dting ah okay thank you. that makes sense. Regex tutorial websites are so freaking complicated
CamperBot
@camperbot
Sep 23 2015 03:24
hugoender sends brownie points to @saintpeter and @dting :sparkles: :thumbsup: :sparkles:
:star: 691 | @saintpeter | http://www.freecodecamp.com/saintpeter
:star: 1232 | @dting | http://www.freecodecamp.com/dting
Hugo
@hugoender
Sep 23 2015 03:24
@SaintPeter can you explain your two examples?
Rex Schrader
@SaintPeter
Sep 23 2015 03:24
@hugoender Haha - you can try http://regex101.com - it's got a nice explainer
@hugoender Sure
@hugoender A character class is described by the brackets [ ] - it means "Match any of the characeters inside. So [abc] would match an a, b, or c
@hugoender You can also do ranges, like [a-z] matches lowercase from a to z
Phou
@nuttdguy
Sep 23 2015 03:26
@JeremyWBean ... (middle, top-right, bottom-right, left-right)
Hugo
@hugoender
Sep 23 2015 03:26
@SaintPeter so [ ] mean that anything inside of there is ORd?
and if you dont use brackets then it's AND?
Phou
@nuttdguy
Sep 23 2015 03:27
@JeremyWBean .. Opps, its (middle, bottom-right, top-right, bottom-left)
Rex Schrader
@SaintPeter
Sep 23 2015 03:27
@hugoender kinda
JeremyWBean
@JeremyWBean
Sep 23 2015 03:28
@Nuttdguy That's a known problem. Thanks for telling me.
CamperBot
@camperbot
Sep 23 2015 03:28
jeremywbean sends brownie points to @nuttdguy :sparkles: :thumbsup: :sparkles:
:warning: jeremywbean already gave nuttdguy points
Rex Schrader
@SaintPeter
Sep 23 2015 03:28
@hugoender Think of regexes as a pattern.
Hugo
@hugoender
Sep 23 2015 03:28
@SaintPeter btw that website you linked is great!
Rex Schrader
@SaintPeter
Sep 23 2015 03:28
@hugoender So you're saying: here is a pattern of "all alphanumerics" followed by "all spaces"
@hugoender I like it :D
Aaron Markle
@aaronmarkle
Sep 23 2015 03:28
these opening waypoints are going by pretty fast lol, just finished through the jquery section in 2 nights of cruising
Phou
@nuttdguy
Sep 23 2015 03:29
:-)
Hugo
@hugoender
Sep 23 2015 03:29
@aaronmarkle wait until you get to the bonfires lol
@aaronmarkle they slowed me down lol
Rex Schrader
@SaintPeter
Sep 23 2015 03:29
@hugoender Note that things like \w are actually just character classes. \w means [a-zA-Z0-9_]
Aaron Markle
@aaronmarkle
Sep 23 2015 03:29
@hugoender that's where i figured there would be some slowdown lol
Rex Schrader
@SaintPeter
Sep 23 2015 03:30
@hugoender You can also "invert" a chracter class, meaning "match anything NOT in this class: [^a-z] would match a character not between lowercase a-z
@hugoender Anyway, does that make sense now?
Hugo
@hugoender
Sep 23 2015 03:30
@SaintPeter it all makes perfect sense. thank you. one more question... g means to keep searching and find them all... what does + mean?
CamperBot
@camperbot
Sep 23 2015 03:30
:warning: hugoender already gave saintpeter points
hugoender sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
Rex Schrader
@SaintPeter
Sep 23 2015 03:32
@hugoender The plus means "one or more of the preceeding" - there are other operators, like * which means "zero or more of the preceeding" and you can also do things like {1,4} which means "between one and 4 of the preceeding"
Hugo
@hugoender
Sep 23 2015 03:34
@SaintPeter dont exactly understand what you mean by "of the preceeding"
can you provide an example?
JeremyWBean
@JeremyWBean
Sep 23 2015 03:35
Rex Schrader
@SaintPeter
Sep 23 2015 03:36
@hugoender Sure: /a+/ means match a, aa, aaaaa, and so on, up to infinite as. It's one or more of the preceeding character. /[a-z]+/ matches one or more characters between a and z
Hugo
@hugoender
Sep 23 2015 03:36
As a side question.. the bonfires don't really provide much troubleshooting or debugging capabilities... is there a good place to run my bonfire code where I can add things like console.log to see what is going on with variable and stuff inbetween?
@SaintPeter how is that different from adding g?
Rex Schrader
@SaintPeter
Sep 23 2015 03:37
@hugoender But you can get some crazy patterns of course. You can even match "one or more" capture groups: /(cat)+/ matches one or more catcatcat
Hugo
@hugoender
Sep 23 2015 03:37
i thought g was supposed to capture all
Rex Schrader
@SaintPeter
Sep 23 2015 03:37
@hugoender Because in combination with other elements it makes a pattern. It's rare to capture a single character.
@hugoender To run your code: http://repl.it
@hugoender No, g means "Find all instances that match the prior pattern in its entirety
Hugo
@hugoender
Sep 23 2015 03:39
so wouldnt /(cat)+/ and /(cat)/g give the same result?
@SaintPeter holy crap that is a great website!! thanks a ton!!!
CamperBot
@camperbot
Sep 23 2015 03:40
hugoender sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: hugoender already gave saintpeter points
Rex Schrader
@SaintPeter
Sep 23 2015 03:40
@hugoender Humm . . . maybe? But a better pattern might be like . . .
/\wa\wa\wa/ which would match banana and papaya
Hugo
@hugoender
Sep 23 2015 03:40
interestingly enough... my code works fine in that repl.it website but the bonfire is still not happy with it...hmm
@SaintPeter whoa whoa whoa you just blew my mind...what!?
lol
Rex Schrader
@SaintPeter
Sep 23 2015 03:41
@hugoender Well, that's way more useful than just matching a string of letters, right? It's all about patterns.
@hugoender or . . . [bp]a[bp]a[ny]a would also match banana and papaya
Hugo
@hugoender
Sep 23 2015 03:43
@SaintPeter just put your example in the regex101 site you sent me and now i understand
thanks again
CamperBot
@camperbot
Sep 23 2015 03:44
if you want to thank someone, put an @ before their name!
Rex Schrader
@SaintPeter
Sep 23 2015 03:44
@hugoender :D Sure thing
dc33
@dc33
Sep 23 2015 03:44
I'm working on "Bonfire: Find the Longest Word in a String"... is there a reason that I would pass 5 of the 6 tests, but not the last one?
Rex Schrader
@SaintPeter
Sep 23 2015 03:45
@dc33 Dunno - what is it say you're getting other than 19?
dc33
@dc33
Sep 23 2015 03:46
@SaintPeter... it doesn't say anything... it just says the "6" from passing the first test.
Rex Schrader
@SaintPeter
Sep 23 2015 03:46
@dc33 Can you share your code?
wiki format
CamperBot
@camperbot
Sep 23 2015 03:46

: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

```js ⇦ Type 3 backticks, then type js or html 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

:pencil: read more about code formatting on the FCC Wiki

Rex Schrader
@SaintPeter
Sep 23 2015 03:46
@dc33 Like so ^ ^
dc33
@dc33
Sep 23 2015 03:47
'''js
function findLongestWord(str) {
str = str.split(' ');
str = str.map(function(num){
return num.length;
});
str = str.sort();
str = str.reverse();
return str[0];
console.log(str[0]);
}'''
CamperBot
@camperbot
Sep 23 2015 03:47
:bulb: to format code use backticks! ``` more info
Rex Schrader
@SaintPeter
Sep 23 2015 03:48
@dc33 Backtick is next to the 1 on your keyboard, same key as the tilde ~, but unshifted
dc33
@dc33
Sep 23 2015 03:48
haha, oops. yup, I'm a noob
DJ
@qualitymanifest
Sep 23 2015 03:49
and you need to put them on separate lines above and below your code
Rex Schrader
@SaintPeter
Sep 23 2015 03:49
@dc33 All I can say is that you win for doing things the hard way. Wow! That code DOES look like it should work, though.
dc33
@dc33
Sep 23 2015 03:50
Got it. Yeah, I don't always have the quickest method. But good to know it 'should' work.
thx
CamperBot
@camperbot
Sep 23 2015 03:50
if you want to thank someone, put an @ before their name!
Rex Schrader
@SaintPeter
Sep 23 2015 03:51
@dc33 ok, Wow
@dc33 WOW
@dc33 I just figured out what your problem is
DTing
@dting
Sep 23 2015 03:51
your sort is lexigraphic
you need a compare function
Rex Schrader
@SaintPeter
Sep 23 2015 03:52
@dc33 Take a look: https://repl.it/BKKo
DTing
@dting
Sep 23 2015 03:53
bf longest
CamperBot
@camperbot
Sep 23 2015 03:53

:fire:Bonfire: Find the Longest Word in a String :link:

function findLongestWord(str) {
  return str.length;
}

findLongestWord('The quick brown fox jumped over the lazy dog');

Return the length of the longest word in the provided sentence.

more info:  bf details | bf links | hint

dc33
@dc33
Sep 23 2015 03:53
@SaintPeter ha, thanks
@dting thanks
CamperBot
@camperbot
Sep 23 2015 03:53
dc33 sends brownie points to @saintpeter and @dting :sparkles: :thumbsup: :sparkles:
:star: 693 | @saintpeter | http://www.freecodecamp.com/saintpeter
:star: 1233 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Sep 23 2015 03:55
You can see the visualization here
Rex Schrader
@SaintPeter
Sep 23 2015 03:56
@dc33 An alternative algorithm: Loop through the words and keep track of the length of the longest word you've seen so far in a variable. If you see a longer word, update your longest word variable. At the end, return the variable with the length of the longest word.
Patrick McWilliams
@patrickmac110
Sep 23 2015 04:25
why are my dots on the unslider not centering?
http://codepen.io/patrcikmac110/full/PPPKXQ/
Mateja Trifunovski
@Matko95
Sep 23 2015 04:28
@patrickmac110 position: absolute; and margin: 0 auto; don't mix i think
Patrick McWilliams
@patrickmac110
Sep 23 2015 04:30
hmm. they used to be centered, so I do'nt think that's the issue
Star Cherrix
@Sparklepaws
Sep 23 2015 05:39
Hey guys, I'm having a small snag on my Polindrome Bonfire and was hoping you all could help. I'm trying to get RegExps working for my .replace, but I must be doing something wrong. Here's an example: str = str.toLowerCase().replace(/s/, '');
Brandon Mellus
@mels065
Sep 23 2015 05:40
Hey everyone. If you have the time, could you go to the HelpZiplines chatroom? I have a question.
SojournerOctocat
@SojournerOctocat
Sep 23 2015 05:43
@Sparklepaws Did you mean .replace(/\s+/g, '')?
Luis Felipe López G.
@luishendrix92
Sep 23 2015 05:50
@Sparklepaws You are missing the global flag g after the forward slash
With the global flag you don't need a + after \s
Star Cherrix
@Sparklepaws
Sep 23 2015 05:50
@SojournerOctocat Actually that fixed a lot of the issues, I forgot about the closing tag and flag.
What is the + even for?
Anthony Albertorio
@tesla809
Sep 23 2015 05:51
Hey guys !
I have a questions
Where can I host fonts for free
I have found some good ones and can't link any to code pen
Star Cherrix
@Sparklepaws
Sep 23 2015 05:53
Another curious thing is that /\W/g doesn't seem to be removing commas and periods
Ah wait, /\W+/g did the trick
SojournerOctocat
@SojournerOctocat
Sep 23 2015 05:57
@Sparklepaws the + denotes 1 or more.
Star Cherrix
@Sparklepaws
Sep 23 2015 05:57
@SojournerOctocat AH thank you! That's helpful.
CamperBot
@camperbot
Sep 23 2015 05:57
sparklepaws sends brownie points to @sojourneroctocat :sparkles: :thumbsup: :sparkles:
:star: 319 | @sojourneroctocat | http://www.freecodecamp.com/sojourneroctocat
Star Cherrix
@Sparklepaws
Sep 23 2015 05:58
I'm not sure if my final code for this Bonfire was acceptable but it passed.
Don Price
@KingHippo
Sep 23 2015 06:06
Can anyone here look at my code for the Bonfire: Confirm the Ending
?
I'm passing all the tests but 1
function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  var words = str.split(" ");

  for (var i in words) {

    if (i > 0 && words[0] == target)  {
      return true;
    }

    else if (str.substr(str.length - 1) == target) {
      return true;
    }

  } 
  return false;
}

end("Bastian", "n", "");
DJ
@qualitymanifest
Sep 23 2015 06:08
which test is that?
Don Price
@KingHippo
Sep 23 2015 06:09
Bonfire: Confirm the Ending
CamperBot
@camperbot
Sep 23 2015 06:09

:fire:Bonfire: Confirm the Ending :link:

function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  return str;
}

end('Bastian', 'n');

Check if a string (first argument) ends with the given target string (second argument).

more info:  bf details | bf links | hint

Luis Felipe López G.
@luishendrix92
Sep 23 2015 06:09
@KingHippo I don't think you should split the string in words, not the right approach, what if the string was something like "this-is-a-kitty-cat" with an ending of "y-cat"?
Don Price
@KingHippo
Sep 23 2015 06:09
@luishendrix92 hmm I didn't think about that.
Luis Felipe López G.
@luishendrix92
Sep 23 2015 06:10
it may work considering the string is considered as a word but let me see if there are more mistakes
Hmm, that -1 should be instead related to the target's length
Don Price
@KingHippo
Sep 23 2015 06:12
@luishendrix92 I'm not sure I understand what you mean?
@qualitymanifest it's confirm the ending
Luis Felipe López G.
@luishendrix92
Sep 23 2015 06:16

"compared string" <-- str
"int" <<-- target

You might want to take the length of "int" (3) and then substract the following from the original string:

"compared string" --> str.substr(str.length - target.length) --> str.substr(15-3) --> str.substr(12)
The character at index 12 happens to be i and substr will start grabbing from there

navicyclical
@navicyclical
Sep 23 2015 06:16
@dting
Luis Felipe López G.
@luishendrix92
Sep 23 2015 06:16
You then need to compared that piece of the string against the target string itself to see if they are the same
navicyclical
@navicyclical
Sep 23 2015 06:16
@qualitymanifest
Luis Felipe López G.
@luishendrix92
Sep 23 2015 06:17
In my example, it will return false since "ing" and "int" aren't the same thing
Anthony Albertorio
@tesla809
Sep 23 2015 06:17
never mind
I figured out a hack around it to link directly to the font hosting site and have them host it for me
Don Price
@KingHippo
Sep 23 2015 06:18
@luishendrix92 thanks, I'll give that a go!
CamperBot
@camperbot
Sep 23 2015 06:18
kinghippo sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star: 374 | @luishendrix92 | http://www.freecodecamp.com/luishendrix92
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:19
please help Bonfire Where do I belong
CamperBot
@camperbot
Sep 23 2015 06:19
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:20
function where(arr, num) {
  // Find my place in this sorted array.
  arr.push(num);
  arr.sort();
    return arr.indexOf(num);
}

where([5,3,20,3], 35, "");
whats wrong with this function two tests are not passing
in bonfire where do i belong
navicyclical
@navicyclical
Sep 23 2015 06:20
hint
CamperBot
@camperbot
Sep 23 2015 06:20
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:21
dont wanna use hint
@navicyclical
I want wrong things in my code with explaination
Kathy C
@tamienne
Sep 23 2015 06:22
@Ali-Haider5 it's because the initial array isn't sorted
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:22
function where(arr, num) {
  // Find my place in this sorted array.
  arr.push(num);
  arr.sort();
    return arr.indexOf(num);
}

where([5,3,20,3], 35, "");
Please help with this
@tamienne you mean I use the ".sort" before pushing "num"?
Kathy C
@tamienne
Sep 23 2015 06:25
no..
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:25
?
Kathy C
@tamienne
Sep 23 2015 06:25
return 0 if the initial array (arr) isn't sorted
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:26
@tamienne plz provide the code
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:27
@Ali-Haider5 Sort doesn't work well for numbers because it sorts alphabetically.
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:27
so ? @SojournerOctocat what should I do then
?
Bill
@kirah1314
Sep 23 2015 06:27
@Ali-Haider5 if you return arr; you will see this [ 20, 3, 3, 35, 5 ]
I don't think that's what you wanted ?
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:28
should I use this in some way?
function compareNumbers(a, b) {
  return a - b;
}
to retrun a sorted array first?
of numbers
@SojournerOctocat
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:29
@Ali-Haider5 I haven't used that, but from what I've read online, that works when sorting numbers. (I don't know why it would work. It doesn't make sense to me.)
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:29
same here
Can you plz give me a full code of bf where do I belong?
Kathy C
@tamienne
Sep 23 2015 06:30
@Ali-Haider5 I dont' really think you're supposed to use sort here
the hint will throw you off because the initial array isn't always sorted properly
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:30
This is what I used, @Ali-Haider5

function where(arr, num) {
    for (var j = 0; j < arr.length; j++) {
        if ( arr[j] >= num) {
            return j;
        }
    }
 }

where([40, 60], 50);
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:31
@tamienne yeah
whaat should I do? @tamienne
@SojournerOctocat can u plz explain this code?
Kathy C
@tamienne
Sep 23 2015 06:32
go through the array and find the first number that is greater than the one you want to insert
return that index
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:33
okay now it makes sense to me
thanks @tamienne
CamperBot
@camperbot
Sep 23 2015 06:33
ali-haider5 sends brownie points to @tamienne :sparkles: :thumbsup: :sparkles:
:star: 270 | @tamienne | http://www.freecodecamp.com/tamienne
x34passenger
@x34passenger
Sep 23 2015 06:34
How do you return undefined?
from a javascript method?
Kathy C
@tamienne
Sep 23 2015 06:34
return undefined;
inside your method
x34passenger
@x34passenger
Sep 23 2015 06:34
thanks @tamienne
CamperBot
@camperbot
Sep 23 2015 06:34
x34passenger sends brownie points to @tamienne :sparkles: :thumbsup: :sparkles:
:star: 271 | @tamienne | http://www.freecodecamp.com/tamienne
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:36
@tamienne don't u think the code SojournerOctocat has provided isn't right as the array isn't sorted?
Kathy C
@tamienne
Sep 23 2015 06:37
that code will work for sorted and unsorted.
Bill
@kirah1314
Sep 23 2015 06:37
@Ali-Haider5 this is how you could use sort() though
function where(arr, num) {
  // Find my place in this sorted array.
  function compareNumbers(a, b) {
  return a - b;
}
     return arr.concat(num).sort(compareNumbers).indexOf(num);
  }

where([40, 60], 50);
Kathy C
@tamienne
Sep 23 2015 06:38
@kirah1314 that code won't work when array isnt' sorted
Bill
@kirah1314
Sep 23 2015 06:38
@tamienne it works, it just passed all the tests :)
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:40
@kirah1314 I am so confused by the compareNumbers function. Do you understand it and what it's doing?
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:40
@tamienne will the code mentioned by SojournerOctocat pass this test
[5, 3, 20, 3], 3 should return 0
Kathy C
@tamienne
Sep 23 2015 06:41
but it wouldnt pass where([1, 5, 3, 20, 3], 3);
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:41
because the indexOf(3) will return some other index than one of a sorted array @tamienne
Bill
@kirah1314
Sep 23 2015 06:41
@SojournerOctocat it's explained on the link I just posted
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:41
@tamienne which code are you taking about?
Bill
@kirah1314
Sep 23 2015 06:41

If compareFunction is supplied, the array elements are sorted according to the return value of the compare function. If a and b are two elements being compared, then:

If compareFunction(a, b) is less than 0, sort a to a lower index than b, i.e. a comes first.
If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.
If compareFunction(a, b) is greater than 0, sort b to a lower index than a.
compareFunction(a, b) must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned then the sort order is undefined.

Kathy C
@tamienne
Sep 23 2015 06:41
it just happens to be correct cause it ended up to be in the 1st slot
i think it's a bug either in the tests or the instructions
navicyclical
@navicyclical
Sep 23 2015 06:43
I've gotten a little farther with the help of @dting and @qualitymanifest but do I still need to have a variable to store the result of the for loop or is my for loop wrong? It's the Factorize bonfire.
function factorialize(num) {
    if (num === 0){
    return 1;
  }
     for (var i=1; i<=num; i++){
     factor = (num * i);
    }

  return num=factor;
}
factorialize(5, '');
CamperBot
@camperbot
Sep 23 2015 06:43
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:43
@kirah1314 I read that before (repeatedly) and I still don't understand what they're saying.
navicyclical
@navicyclical
Sep 23 2015 06:43
bonfire factorize
CamperBot
@camperbot
Sep 23 2015 06:43
Sorry, can't find a bonfire called factorize. [ Check the map? ]
Kathy C
@tamienne
Sep 23 2015 06:43
either make the test arrays passed in sorted properly or the instructions to say the 1st spot it can fit
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:43
@tamienne which code are you taking about?of kirah1314 or of SojournerOctocat. I am taking about the code of SojournerOctocat that it may not pass the test you have mentioned.
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:43
bf factorialize
CamperBot
@camperbot
Sep 23 2015 06:43

:fire:Bonfire: Factorialize a Number :link:

function factorialize(num) {
  return num;
}

factorialize(5);

Return the factorial of the provided integer.

more info:  bf details | bf links | hint

DTing
@dting
Sep 23 2015 06:43
@navicyclical
declare that factor variable and assign it an initial value
var factor = 1;
navicyclical
@navicyclical
Sep 23 2015 06:44
@dting - before the for loop?
DTing
@dting
Sep 23 2015 06:44
then in the loop you want to assign factor equal to the result of multiplying factor by something, not num
yes
Kathy C
@tamienne
Sep 23 2015 06:45
@Ali-Haider5 the bonfire itself. if they pass in a sorted array your code would work (when you add in Kirah's compare function)
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:45
@tamienne which code are you taking about?of kirah1314 or of SojournerOctocat. I am taking about the code of SojournerOctocat that it may not pass the test you have mentioned.i-e ([5, 3, 20, 3], 3 should return 0)
DTing
@dting
Sep 23 2015 06:45
after you finish the problem i have some notes about that one you can check out https://github.com/dting/fccbonfires/blob/master/basic/Basic%2003%20-%20Factorialize%20a%20Number.ipynb
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:46
ok @tamienne Would you mind me staring you for future disturbing you? yes or no?
navicyclical
@navicyclical
Sep 23 2015 06:46
@dting it works!
Kathy C
@tamienne
Sep 23 2015 06:46
lol.. no problem.
Bill
@kirah1314
Sep 23 2015 06:47
@SojournerOctocat I'm not familiar enough to explain it. I think @dting would know
navicyclical
@navicyclical
Sep 23 2015 06:47
@camperbot
Bill
@kirah1314
Sep 23 2015 06:48
@SojournerOctocat the logic seems to be this though but not sure if it's much help
function compare(a, b) {
  if (a is less than b by some ordering criterion) {
    return -1;
  }
  if (a is greater than b by the ordering criterion) {
    return 1;
  }
  // a must be equal to b
  return 0;
}
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:48
@kirah1314 Why doesn't it subtract?
DTing
@dting
Sep 23 2015 06:48
the function you pass to the sort function indicates how the values should be ordered
you can compare things that are not numbers
Bill
@kirah1314
Sep 23 2015 06:49
that's to sort strings
sorting numbers then a-b
Ali-Haider5
@Ali-Haider5
Sep 23 2015 06:50
@SojournerOctocat Have you read any book on javascript or on programming itself?
AnandSiyote
@AnandSiyote
Sep 23 2015 06:50
challenges/bonfire-confirm-the-ending "He has to give me a new name", "name".. How to assert this condition??
Bill
@kirah1314
Sep 23 2015 06:50
thanks @dting
CamperBot
@camperbot
Sep 23 2015 06:50
kirah1314 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1234 | @dting | http://www.freecodecamp.com/dting
SojournerOctocat
@SojournerOctocat
Sep 23 2015 06:50
@Ali-Haider5 No, I haven't. Do you have any that you recommend?
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 06:54
bf chunkey monkey
CamperBot
@camperbot
Sep 23 2015 06:54
Sorry, can't find a bonfire called chunkey monkey. [ Check the map? ]
Bill
@kirah1314
Sep 23 2015 06:55
help monkey
CamperBot
@camperbot
Sep 23 2015 06:55

:point_right: bonfire chunky monkey [wiki]

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

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

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

How to approach the bonfire

The helpful links suggest to use Array.push() so let's start by first creating a new array to store the smaller arrays we will soon have like this:

var newArray = [];

Next we'll need a for loop to loop through arr then finally we need a method to do the actual splitting and we can use Array.slice() to do that. The key to this bonfire is understanding how a for loop, size, Array.slice() and Array.push() all work together.

How does a for loop and Array.slice() work

For Loop

:pencil: read more about bonfire chunky monkey on the FCC Wiki

Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 06:58
@kirah1314 thanks :)
CamperBot
@camperbot
Sep 23 2015 06:58
thedigitalmonk sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 262 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 06:59
Btw anybody knows where these brownie points get accumulated? I can't see it on the profile page.
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:00
help brownie
CamperBot
@camperbot
Sep 23 2015 07:00

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 07:01
Oooh! I thought that number only shows the number of challenges I have completed.
@SojournerOctocat thanks. I seriously need to start using this help option more.
CamperBot
@camperbot
Sep 23 2015 07:01
thedigitalmonk sends brownie points to @sojourneroctocat :sparkles: :thumbsup: :sparkles:
:star: 322 | @sojourneroctocat | http://www.freecodecamp.com/sojourneroctocat
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:10
Yes, there's useful info there
Ali-Haider5
@Ali-Haider5
Sep 23 2015 07:11

@SojournerOctocat I asked this question because I am going through same confusion at every challenge as you are . Here are the things I am going to go through for my javascript and programming knowlede:
For programming: harvard's cs50 or MIT 6.00x(I recommend cs50 which is in more details and includes more languages. Whereas 6.00x only focuses on Python)
For Javascript: eloquentjavascript (eloquentjavascript.net (online version)) the offline one also available for free.
For Html and Css: HTML and CSS: Design and Build Websites by Jon Duckett(He also wrote a very good book on Javascript and jQuery)

AND For reference :Javascript the definitive guide 6th edition

SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:13
@Ali-Haider5 Thank you! I've heard a number of people recommending Eloquent Javascript in these chat rooms, but I didn't know there was a free online version.
CamperBot
@camperbot
Sep 23 2015 07:13
sojourneroctocat sends brownie points to @ali-haider5 :sparkles: :thumbsup: :sparkles:
:star: 189 | @ali-haider5 | http://www.freecodecamp.com/ali-haider5
Ali-Haider5
@Ali-Haider5
Sep 23 2015 07:13
This message was deleted
This message was deleted
CamperBot
@camperbot
Sep 23 2015 07:15
:star: 322 | @sojourneroctocat | http://www.freecodecamp.com/sojourneroctocat
Ali-Haider5
@Ali-Haider5
Sep 23 2015 07:16
@SojournerOctocat where have you reached in FCC?
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:17
I am working on the First Zipline. Slowly, because I have absolutely no idea what I'm doing.
The resources you just gave me should help.
Kathy C
@tamienne
Sep 23 2015 07:17
The hardest part about the ziplines for me is the look =)
Bill
@kirah1314
Sep 23 2015 07:18
imo, the ziplines are so much more fun than the bonfires
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:19
@kirah1314 How so?
x34passenger
@x34passenger
Sep 23 2015 07:19
how do you assign undefined to a variable?
Bill
@kirah1314
Sep 23 2015 07:19
get to use html, css, js, jquery, bootstrap
all front-end stuff and you can visually see what you're creating
Kathy C
@tamienne
Sep 23 2015 07:22
mix it up.. use angular for one, vanilla js for another, jquery for another. you'll get a better feel for each of them
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:22
I like the bonfires more. I feel as if I don't have enough knowledge to do the Ziplines.
Bill
@kirah1314
Sep 23 2015 07:23
I just finished the angular waypoints so going to use angular on the next set of ziplines
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 07:23
Guys why this returning and array inside an array? Can't seem to figure it out...
function chunk(arr, size) {      
      var temp = []; 
      var result = []; 

      for (i=0; i < arr.length; i+= size) {
        temp.push(arr.slice(i, i+size));
      }

      result.push(temp);

      return result;

    }

    console.log(chunk(["a", "b", "c", "d"], 2, ""));
Bill
@kirah1314
Sep 23 2015 07:23
@SojournerOctocat bootstrap is your best friend
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:24
@kirah1314 I don't know how to use bootstrap either.
Kathy C
@tamienne
Sep 23 2015 07:24
@thedigitalmonk because you're pushing arrays (temp) into result (another array)
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 07:25
Oh so I just need to return temp; then?
Kathy C
@tamienne
Sep 23 2015 07:25
yeah
Bill
@kirah1314
Sep 23 2015 07:25
@SojournerOctocat they have a basic template to start with
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:26
@kirah1314 They do. I saw that today. I don't like the template, but at least it's something to build from.
Bill
@kirah1314
Sep 23 2015 07:26
that's what I did then I just looked at all the css, components, etc
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 07:26
@tamienne thanks! that worked. Can't recall why I created another array anyway. :/
CamperBot
@camperbot
Sep 23 2015 07:26
thedigitalmonk sends brownie points to @tamienne :sparkles: :thumbsup: :sparkles:
:star: 272 | @tamienne | http://www.freecodecamp.com/tamienne
Bill
@kirah1314
Sep 23 2015 07:26
and try the ones that I want to use, trial and error
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 07:27
Guys is it okay if I am only able to finish like 5 bonfires in 3 hours? I am beginning to feel I am very slow at this. :/
Kathy C
@tamienne
Sep 23 2015 07:27
@thedigitalmonk could be you were going to assign temp to a slice versus push to temp array
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:27
@thedigitalmonk Yes. Sometimes solving is quick, sometimes it's not.
Bill
@kirah1314
Sep 23 2015 07:28
@thedigitalmonk that's a really good start!
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 07:28
Not sure if I understand what you are saying @SojournerOctocat
@kirah1314 really? Most campers I are almost zipping through the ziplines!
Kathy C
@tamienne
Sep 23 2015 07:28
@thedigitalmonk everyone learns in different speeds.
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:29
@thedigitalmonk Five bonfires in 3 hours is okay. Sometimes, you'll be even quicker and sometimes it may take days to solve a bonfire.
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 07:29
days? Yikes!
Kathy C
@tamienne
Sep 23 2015 07:29
i highly doubt people are zipping through the ziplines. Unless they're cheating. You have to do alot of research to lookup api's and such
Bill
@kirah1314
Sep 23 2015 07:29
@SojournerOctocat I'm not sure if you know but you can click on the bootstrap examples then open up developer tools on chrome and you can see the examples codes
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:30
@kirah1314 What bootstrap examples?
to examples and using the framework
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:32
@kirah1314 I don't use Chrome. Thanks! That
CamperBot
@camperbot
Sep 23 2015 07:32
sojourneroctocat sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 263 | @kirah1314 | http://www.freecodecamp.com/kirah1314
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:32
That's helpful!
Bill
@kirah1314
Sep 23 2015 07:32
it should work for anywhere you can open up dev tools
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:33
@kirah1314 Yes, I'm doing that now and it's very helpful!
Bill
@kirah1314
Sep 23 2015 07:33
lol ok nice!
@SojournerOctocat did you create an account on codepen?
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:35
@kirah1314 Yes, I did.
Bill
@kirah1314
Sep 23 2015 07:36
you can check out other people's codes and see how the codes tie together. I mean non-FCC projects
SojournerOctocat
@SojournerOctocat
Sep 23 2015 07:36
@kirah1314 Yes, what I've seen on some of those… Wow. Quite impressive.
And intimidating. I can't even imagine being able to create pages like that. I mean, I know that with practice, I'll get there, but wow.
Bill
@kirah1314
Sep 23 2015 07:38
yeah there's some very sophisticated stuff there
Michael Cheung
@m6cheung
Sep 23 2015 08:10
how do I make an entire div box clickable?

i trie wrapping my div around an a tag like this:

<a href="#"><div class="projects" id="first"><a href = #>asd</a></div></a>

I'd prefered if someone could teach me sing vanilla JS, but if its not possible HTML is fine
Malcolm
@noinkling
Sep 23 2015 08:16
@m6cheung Wrapping it in an <a> tag should work.
Michael Cheung
@m6cheung
Sep 23 2015 08:17
@noinkling isn't that what I did?
Malcolm
@noinkling
Sep 23 2015 08:17
yes
Michael Cheung
@m6cheung
Sep 23 2015 08:17
@noinkling it didn't work though :(
is there a way using javascript?
Malcolm
@noinkling
Sep 23 2015 08:18
yup you can attach a click handler directly to the div
Michael Cheung
@m6cheung
Sep 23 2015 08:19
@noinkling Should I do this in the scripts section or do I do it within the div tag?
Malcolm
@noinkling
Sep 23 2015 08:20
Oh I should note that if you're using Codepen, you need to add target="_blank" to your <a> tags that link externally. That might be your problem, try that first.
Michael Cheung
@m6cheung
Sep 23 2015 08:20
@noinkling oh no, I'm just using notepad++
@noinkling should I use codepen?
Malcolm
@noinkling
Sep 23 2015 08:24
Depends what you're doing.
Are you working on your profile?
I mean portfolio.
dht0my
@dht0my
Sep 23 2015 08:25
Hello, can somebody help me with this challenge Waypoint: Check the Length Property of a String Variable
I don't understand what I am supposed to do
Michael Cheung
@m6cheung
Sep 23 2015 08:27
@noinkling yes sir
@dht0my you are trying to find out how many characters a string contains
dht0my
@dht0my
Sep 23 2015 08:28
yes @m6cheung
i have used .length
Malcolm
@noinkling
Sep 23 2015 08:29
@m6cheung Developing in a text editor is fine but Codepen allows you to include libraries/preprocessors easily and avoid a bit of boilerplate. It's also easier to share with others for help. Eventually you'll need to paste everything across anyway in order to submit if it's for a Zipline. But it's up to you.
Michael Cheung
@m6cheung
Sep 23 2015 08:29
@noinkling ok, I'm going to use codepen, it's a lot easier to deal with anyway
@noinkling just one question after putting a target=_blank, the windows opens in a new tab but why is it untitled?
@noinkling the link still says http://google.com
Malcolm
@noinkling
Sep 23 2015 08:31
@m6cheung Paste your actual code again
Michael Cheung
@m6cheung
Sep 23 2015 08:31
<body>

  <ul id="nav-bar">
    <li><a target="_blank" a href=#>Home</a></li>
    <li><a target="_blank" a href=#>About</a></li>
    <li><a target="_blank" a href=#>Projects</a></li>
    <li><a target="_blank" a href=#>Contact</a></li>
  </ul>

  <h3 style="text-align: left">Michael Cheung</h3>

  <a target="_blank" href="htttp://google.com" <div class="projects" id="first">
    <a target="_blank" href="http://google.com"></a>
    </div>
  </a>
  <div class="projects" id="second"><a href=#>asd</a></div>
  <div class="projects" id="third"><a href=#>asd</a></div>

</body>
Malcolm
@noinkling
Sep 23 2015 08:32
you're missing a closing > on your outer a element
Michael Cheung
@m6cheung
Sep 23 2015 08:33
@noinkling oh man i derpped
Malcolm
@noinkling
Sep 23 2015 08:33
I have those moments all the time lol
Michael Cheung
@m6cheung
Sep 23 2015 08:33
@noinkling wait it didnt make any difference
@noinkling err in fact my div is unclickable after I close dit
Malcolm
@noinkling
Sep 23 2015 08:35
@m6cheung also htttp...
You have an extra t
Michael Cheung
@m6cheung
Sep 23 2015 08:35
@noinkling o my goodness I'm blind haha
@noinkling it works now
thanks haha
CamperBot
@camperbot
Sep 23 2015 08:36
if you want to thank someone, put an @ before their name!
Michael Cheung
@m6cheung
Sep 23 2015 08:36
@noinkling thnkas
@noinkling thanks
CamperBot
@camperbot
Sep 23 2015 08:36
m6cheung sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:star: 272 | @noinkling | http://www.freecodecamp.com/noinkling
Malcolm
@noinkling
Sep 23 2015 08:37
@m6cheung no problem, it's easy to get tripped up by little details
Michael Cheung
@m6cheung
Sep 23 2015 08:37
@noinkling can you teach me how I would doit in javascript?
how do I actually target the div box
Malcolm
@noinkling
Sep 23 2015 08:40
@m6cheung I only know using jQuery - you would do something like:
$("#first").click(function() {
  window.location = "http://www.google.com";
};
Although I don't know if using window.location is a good idea on Codepen, it might be better to target an already existing a element instead.
Michael Cheung
@m6cheung
Sep 23 2015 08:42
@noinkling thanks
CamperBot
@camperbot
Sep 23 2015 08:42
m6cheung sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:warning: m6cheung already gave noinkling points
Michael Cheung
@m6cheung
Sep 23 2015 08:42
@noinkling ill keep this in mind, on codepen it says JS, can I still use jQuery?
Malcolm
@noinkling
Sep 23 2015 08:44

So like:

$("#first").click(function() {
  $("#some-a-element").click();
};

Note that the inner click() method does something different to the outer one, because it doesn't take an argument. There are a few methods in jQuery like that.

jQuery is just a library, if you click the cog icon next to the JS panel you can add it.
Michael Cheung
@m6cheung
Sep 23 2015 08:45
@noinkling ohhh ok, I got it then thanks for the help man
CamperBot
@camperbot
Sep 23 2015 08:45
m6cheung sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:warning: m6cheung already gave noinkling points
Malcolm
@noinkling
Sep 23 2015 08:45
The first Zipline exercise should have told you how to do this.
Michael Cheung
@m6cheung
Sep 23 2015 08:46
@noinkling yea it did, it slipped my mind
Jordan Shackelford
@JordanShackelford
Sep 23 2015 09:06
My javascript stopped working all of a sudden and I think it's blocking my api call

Anybody know what this means?

Uncaught SecurityError: Blocked a frame with origin "http://s.codepen.io" from accessing a frame with origin "http://codepen.io". Protocols, domains, and ports must match.

Michael Cheung
@m6cheung
Sep 23 2015 09:12
how do I extend my html to scroll down, I feel like I'm only limited to one page at the moment
Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 09:13
bf mutations
CamperBot
@camperbot
Sep 23 2015 09:13

:fire:Bonfire: Mutations :link:

function mutation(arr) {
  return arr;
}

mutation(['hello', 'hey']);

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

more info:  bf details | bf links | hint

Thomson Muriyadan
@thedigitalmonk
Sep 23 2015 09:13
bf hint
CamperBot
@camperbot
Sep 23 2015 09:13
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
azaleas
@azaleas
Sep 23 2015 09:17

Hi every1, I'm on my 4th Zipline - Pomodoro Clock. I got to the point when I can make a countdown:

if (wr > 0){
countDown(wr); // countDown function, wr = time for the timer;
wr--;
}

the code works fine, I get the countdown for a minute, with this. And each time, I get to remove one minute. The thing is My code won't work the way I want it to work in a loop.

while(wr>0){
countDown(wr); // countDown function, wr = time for the timer;
wr--
}

Here, My function get's only the wr == 1; loop doesn't wait for my function to finish and just transfers wr. How can I make the while loop wait so that my function can finish the job, then while loop can go on?

Stefano
@katteo
Sep 23 2015 09:24
bf seek and destroy
CamperBot
@camperbot
Sep 23 2015 09:24

:fire:Bonfire: Seek and Destroy :link:

function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

Stefano
@katteo
Sep 23 2015 09:24
hint
CamperBot
@camperbot
Sep 23 2015 09:24
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Stefano
@katteo
Sep 23 2015 09:24
hint
CamperBot
@camperbot
Sep 23 2015 09:24
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Ammar Ali Shah
@AmmarAliShah
Sep 23 2015 09:58
Need help with the second zipline
rulanfuse
@rulanfuse
Sep 23 2015 10:18
@AmmarAliShah: where are you stuck?
Sandeep Lakka
@asandyz
Sep 23 2015 10:22
hello world
CamperBot
@camperbot
Sep 23 2015 10:22

welcome to FreeCodeCamp @asandyz!

Sandeep Lakka
@asandyz
Sep 23 2015 10:22
I'm having little problem with css
I have a intranet website on which there was checkbox with label
When I'm using Firefox or chrome or internet explorer 6, the clickable area is confined to the label and checkbox
But when using IE 10/11 , checkbox's clickable area was whole row
Malcolm Brooks
@brooksofmaine
Sep 23 2015 10:27
I'm caught in an infinite while loop in Chrome. I force exit, re-open, click "learn" and open up the bonfire I was working on. The javascript starts executing immediately, before I have time to edit it. Back into the infinite loop it goes. Any suggestions?
Sandeep Lakka
@asandyz
Sep 23 2015 10:27
@brooksofmaine is it with string "$$" ?
if so, please clear the cache and try again
hope it helps
Malcolm Brooks
@brooksofmaine
Sep 23 2015 10:28
Hi @asandyz .. not sure what "$$" means. But I am going to follow up on your idea of clearing the cache...
rulanfuse
@rulanfuse
Sep 23 2015 10:29
@asandyz try to use web developer tools or other css inspector to see what the css is doing there... and simplify the css, get rid of extra elements, until you find what is wrong with that part
Ammar Ali Shah
@AmmarAliShah
Sep 23 2015 10:30
@rulanfuse need help using the API
rulanfuse
@rulanfuse
Sep 23 2015 10:33
@AmmarAliShah so what API are you using? is there's someone here who knows the API you're trying to use, you might get some replies
otherwise, every API can be different
Malcolm Brooks
@brooksofmaine
Sep 23 2015 10:34
@asandyz Clearing the cache worked. Let's see if you get a brownie point with this: @asandyz++
or this @asandyz ++
OK, this: Thank you, @asandyz!
CamperBot
@camperbot
Sep 23 2015 10:35
brooksofmaine sends brownie points to @asandyz :sparkles: :thumbsup: :sparkles:
:star: 175 | @asandyz | http://www.freecodecamp.com/asandyz
Sandeep Lakka
@asandyz
Sep 23 2015 10:42
@brooksofmaine :D
Ankit Panwar
@coderNoob
Sep 23 2015 10:46
Has anyone done the "Random Quote Machine" zipline using the "http://forismatic.com/en/api/" ?
Ammar Ali Shah
@AmmarAliShah
Sep 23 2015 11:00
@coderNoob @rulanfuse http://forismatic.com/en/api/
Ankit Panwar
@coderNoob
Sep 23 2015 11:02
@AmmarAliShah Did you use it in your zipline? If so, can you provide me with your codepen so that I can pick up some hints?
screeps-chat
@screeps-chat
Sep 23 2015 11:17
Waypoint: Iterate over arrays using map() is saying my function isnt a function
array = array.map(function(val){
  return val+3;
})
and never mind, checked the github issues for that waypoint and found the issue
x34passenger
@x34passenger
Sep 23 2015 11:30
can you assign undefined to a variable?
Andi
@p3rand0r
Sep 23 2015 11:35
can someone please explain me what i have to do in the Bonfire: Seek and Destroy exercise? :/
Jalita
@UsefulPixels
Sep 23 2015 11:39
Hello guys (and girls) I wonder if someone could maybe help me with this exercise? "Waypoint: Use Bracket Notation to Find the NthtoLast Character in a String”
var secondToLastLetterOflastName = lastName[lastName.length - 2 ];
Solved it now! Ignore my last post
Realised it wasn’t defined.
Jalita
@UsefulPixels
Sep 23 2015 12:23

Hello again, now I do have an issue with this one "Waypoint: Modify Array Data With Indexes”

var ourArray = [1,2,3];
ourArray[1] = 3;
// ourArray[1] now equals [1,3,3].
var myArray = [1,2,3];

// Only change code below this line.

myArray[0] 3;

This is what I wrote: myArray[0] 3;

Stathis Mitropoulos
@StathisMitro
Sep 23 2015 12:26
Hello to everyone, I would like some help! Take a look to my code about Mutations (Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.) and tell what I do wrong???

function mutation(arr) {
var element1 = arr[0].toLowerCase();
var element2 = arr1.toLowerCase();
var sElement2 = element2.split("");
var sElement2Length = sElement2.length;

for(var i = 0; i < sElement2Length; i++){
var checkLetter = sElement2[i];
var condition = element1.indexOf(checkLetter);
if (condition > -1){
return true;
}
else{
return false;
}
}

}

mutation(["hello", "hel"], "");

Wiko
@wico216
Sep 23 2015 12:35
@UsefulPixels
@UsefulPixels myArray[0] = 3;
Star Cherrix
@Sparklepaws
Sep 23 2015 12:36
Hmm, so I'm having some issues with "Bonfire: Return Largest Numbers in Arrays"
Jalita
@UsefulPixels
Sep 23 2015 12:36
Hi @wico216 , gosh, such a stupid mistake, thank you :smile:
Star Cherrix
@Sparklepaws
Sep 23 2015 12:36
Does .sort not sort 4-digit numbers properly?
function largestOfFour(arr) {
  for(i in arr){
    arr[i] = arr[i].sort();
  }
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], "");
Star Cherrix
@Sparklepaws
Sep 23 2015 12:42
It returns the last array like this: [1, 1000, 1001, 857]. Seemingly ignoring the fact that the 4 digit numbers are "higher"
Coira Ellison
@Coira
Sep 23 2015 12:42
@Sparklepaws .sort() sorts in alphabetical order unless given a sorting function
have a look here on how to get it to sort in numerical order https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Star Cherrix
@Sparklepaws
Sep 23 2015 12:43
@Coira Will do, thank you!
CamperBot
@camperbot
Sep 23 2015 12:43
sparklepaws sends brownie points to @coira :sparkles: :thumbsup: :sparkles:
:star: 229 | @coira | http://www.freecodecamp.com/coira
Star Cherrix
@Sparklepaws
Sep 23 2015 12:50
Well, this seems to pass the test. Not sure if it's sloppy or not, and I still have no idea how the sort function I added is comparing values, but it worked:
function largestOfFour(arr) {
  for(i in arr){
    arr[i] = arr[i].sort(function(a, b){
      return a - b;
    }).pop();
  }
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], "");
Coira Ellison
@Coira
Sep 23 2015 12:52
yep, that's pretty much it
i don't know when fcc goes over functional programming (e.g. foreach, filter etc), but sort() will make more sense then
also, i've seen people recommend you don't use sort() because it computationally more "expensive" than using 2 for loops (sorting runs through each array more often than going through it once and looking for the largest number)
Star Cherrix
@Sparklepaws
Sep 23 2015 12:56
I actually thought about using 2 loops at a point but the sorting seemed more compact so I went with that. Interesting though, I wouldn't expect it to be more taxing than 2 for loops.
Coira Ellison
@Coira
Sep 23 2015 12:57
yeah, i find sort much easier to read than having 2 for loops, and that's how i did it myself, but sort() will have to go through the array several times
http://www.sorting-algorithms.com/ run a sort() and see how many times the triangle has to go through the array
Star Cherrix
@Sparklepaws
Sep 23 2015 12:59
Ahh I see, I suppose that makes sense. I imagine the difference in calculation power is ridiculously small but it's still nice to have that knowledge.
DEBOJIT KAKOTI
@debojitkakoti
Sep 23 2015 13:19
hi anyone plz help me why str.repeat(1) is not working?
stuck at bonfire 9 . repeat string
Soumya Rauth
@soumyaRauth
Sep 23 2015 13:45
donno what is wrong..? can anyone help?
function diff(arr1, arr2) {

  var newArr = [];
  var newArr2=[];
  var newArr3=[];
  var newArr4=[];
  var x=0;

 newArr2=arr1.concat(arr2);
 newArr4=newArr2; 


  function filtering(value,indexOfElement){

    newArr4=newArr2.slice((indexOfElement+1), (newArr2.length));




    for(var j=0;j<newArr4.length;j++){

    if(value===newArr4[j]){

     return false;

    }
     else{

           x=1;
          }

      }


    newArr=newArr2.filter(filtering);

   return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
venson7
@venson7
Sep 23 2015 13:45
Hello everyone! What's with the 220 bonfire? I'm talking about the 5th assertion, the one with the comma separating the function call from another array. Anyone figure that out?
Aaron Freidus
@shadowfool
Sep 23 2015 14:02
@venson7 can you post your code and the name of the bonfire please
Blauelf
@Blauelf
Sep 23 2015 14:04
Where do people get those numbers? Is it their personal score?
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:05
Hi everyone, I am having a strange problem. I think it's a bug. #123 is asking me to do a simple length check for the var lastName = "Lovelace"; so I am writing:
lastName.length;
Can someone advise, I'm sure it's correct
Blauelf
@Blauelf
Sep 23 2015 14:06
@Jojokats What do you mean with "#123"? Do you have a name for us?
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:08
Hi @Blauelf sorry about the number
Blauelf
@Blauelf
Sep 23 2015 14:08
I assume that you meant the "Check the Length Property of a String Variable". Did you assign lastName.length to the variable that will be tested?
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:09
Thanks @Blauelf i wrote: lastName.length; only
CamperBot
@camperbot
Sep 23 2015 14:09
jojokats sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 303 | @blauelf | http://www.freecodecamp.com/blauelf
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:09
Isn't this correct @Blauelf
It won't work, I tried refreshing my page, but I think there's a bug
Blauelf
@Blauelf
Sep 23 2015 14:10
This will evaluate the length, but the program later checks for the variable lastNameLength to be set to this length.
venson7
@venson7
Sep 23 2015 14:10
function drawer(price, cash, cid) {
  var change = cash-price;
  var changeArr = [];
  var times;


  switch(true){
    case(change>=100.00):
      times = Math.floor(change/100.00);
      if(times*100.00<=cid[8][1]){
        cid[8][1] -= times*100.00;
      }else{
        times= Math.floor(cid[8][1]/100.00);
        cid[8][1] = 0;
      }
      change -= times*100;
      if(times>0){
        changeArr.push([cid[8][0], times*100.00]);
      }

    case(change>=20.00):
      times = Math.floor(change/20.00);
      if(times*20.00<=cid[7][1]){
        cid[7][1] -= times*20.00;
      }else{
        times= Math.floor(cid[7][1]/20.00);
        cid[7][1] = 0;
      }
      change -= times*20;
      if(times>0){
        changeArr.push([cid[7][0], times*20.00]);
      }

    case(change>=10.00):
      times = Math.floor(change/10.00);
      if(times*10.00<=cid[6][1]){
        cid[6][1] -= times*10.00;
      }else{
        times= Math.floor(cid[6][1]/10.00);
        cid[6][1] = 0;
      }

      change -= times*10.00;
      if(times>0){
        changeArr.push([cid[6][0], times*10.00]);
      }

    case(change>=5.00):
      times = Math.floor(change/5.00);
      if(times*5.00<=cid[5][1]){
        cid[5][1] -= times*5.00;  
      }else{
        times= Math.floor(cid[5][1]/5.00);
        cid[5][1] = 0;
      }
      change -= times*5.0;
      if(times>0){
        changeArr.push([cid[5][0], times*5.00]);
      }

    case(change>=1.00):
      times = Math.floor(change/1.00);
      if(times*1.00<=cid[4][1]){
        cid[4][1] -= times*1.00;  
      }else{
        times= Math.floor(cid[4][1]/1.00);
        cid[4][1] = 0;
      }
      change -= times*1.0;
      if(times>0){
        changeArr.push([cid[4][0], times*1.00]);
      }
    case(change>=0.25):
      times = Math.floor(change/0.25);
      if(times*0.25<=cid[3][1]){
        cid[3][1] -= times*0.25;  
      }else{
        times= Math.floor(cid[3][1]/0.25);
        cid[3][1] = 0;
      }
      change -= times*0.25;
      if(times>0){
        changeArr.push([cid[3][0], times*0.25]);
      }

    case(change>=0.10):
      times = Math.floor(change/0.10);
      if(times*0.10<=cid[2][1]){
        cid[2][1] -= times*0.10;  
      }else{
        times= Math.floor(cid[2][1]/0.10);
        cid[2][1] = 0;
      }
      change -= times*0.10;
      if(times>0){
        changeArr.push([cid[2][0], times*0.10]);
      }

    case(change>=0.05):
      times = Math.floor(change/0.05);
      if(times*0.05<=cid[1][1]){
        cid[1][1] -= times*0.05;  
      }else{
        times= Math.floor(cid[1][1]/0.05);
        cid[1][1] = 0;
      }
      change -= times*0.05;
      if(times>0){
        changeArr.push([cid[1][0], times*0.05]);
      }

    case(change>=0.01):
      times = Math.floor(change/0.01);
      if(times*0.01<=cid[0][1]){
        cid[0][1] -= times*0.01;  
      }else{
        times= Math.floor(cid[0][1]/0.01);
        cid[0][1] = 0;
      }
      change -= times*0.01;
      if(times>0){
        changeArr.push([cid[0][0], times*0.01]);
      }

    }
    console.log(cid);
    if(change>0){
      return "Insufficient Funds";
    }else if(isEmpty(cid)){
      console.log("here");
      return "Closed";
    }else{
      console.log(changeArr);
      return changeArr;
    }
  }


function isEmpty(arr){
  for(var i=0;i<arr.length;i++){
    if(arr[i][1] != 0){
      return false;
    }
  }
  return true;
}
it's Bonfire: Exact Change.
Aleksander Gębicki
@Takumar
Sep 23 2015 14:11
@soumyaRauth What for you have introduced variable x ? It is not used later in your code for anything.
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:11
@Blauelf ok so then I have to check for lastNameLength.length; I don't think this is correct
Blauelf
@Blauelf
Sep 23 2015 14:12
@Jojokats No, just assign the lastName.length to lastNameLength, as it is done for firstName.length above.
Copy and adapt that line. It's designed to be easy ;)
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:14
@Blauelf I did it won't work: lastName.length;
@Blauelf I tried it on console.log and it works
Blauelf
@Blauelf
Sep 23 2015 14:15
Have you tried lastNameLength = lastName.length;?
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:15
@Blauelf no, I will try, thanks,
CamperBot
@camperbot
Sep 23 2015 14:15
jojokats sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: jojokats already gave blauelf points
Blauelf
@Blauelf
Sep 23 2015 14:15
Just as the other line reads firstNameLength = firstName.length;...
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:16
Oh my gosh @Blauelf it worked, I have to review the question Thanks!!!!!!!!!!!!!!
CamperBot
@camperbot
Sep 23 2015 14:16
jojokats sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: jojokats already gave blauelf points
Blauelf
@Blauelf
Sep 23 2015 14:17
The script tests whether the variable lastNameLength is set to the correct value. So without the assignment, it will fail.
Aleksander Gębicki
@Takumar
Sep 23 2015 14:20

@soumyaRauth your code doesn't work now because you have forgotten to close your filtering function body. Add one curly bracket before newArr=newArr2.filter(filtering);:

     else{
           x=1;
          }
      }
  }
  newArr=newArr2.filter(filtering);
   return newArr;
}
diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);

This will allow you to start your program but I still don't know what for you prepared x variable?

Jalita
@UsefulPixels
Sep 23 2015 14:24

Hi, I can only solve one of the issues with this one”Waypoint: Manipulate Arrays With shift”

var ourArray = ["Stimpson", "J", ["cat"]];
ourRemoved = ourArray.shift();
// ourArray now equals ["J", ["cat"]].

var myArray = ["John", 23, ["dog", 3]];
// Only change code below this line.
ourRemoved = myArray.shift();


var myRemoved = myArray; // This should be ["John"] and myArray should now be [23, ["dog", 3]].

Can’t figure out what I should put below this one. myRemoved should containt “John” but this exercise removes the first value? Here the first value should stay? So confused… Anyone who can bring some light to me?

Blauelf
@Blauelf
Sep 23 2015 14:24
@Takumar Not the only variable not used. Same for newArr3, and with another starting value for j, there would be no need for the creation of newArr4.
Paulie
@Paulie-P
Sep 23 2015 14:24
Hey guys, is anyone around to help solve a problem I have? I'm trying to complete the 'Title case a sentence' bonfire and currently have this:
  function titleCase(str) {var string = str.toLowerCase();
  string = string.split(' ')
  string = string.map(function(val) {
    val[0].toUpperCase;
  });

for (var i = 0; i < string.length - 1; i++) {
  string[i] = string[i].charAt(0).toUpperCase();
}

  return string;
}

titleCase("I'm a little tea pot", "");
CamperBot
@camperbot
Sep 23 2015 14:24
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Blauelf
@Blauelf
Sep 23 2015 14:24
@UsefulPixels Change ourRemoved to myRemoved ;)
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:25
@Blauelf thanks i didn't know we had to store this in lastNameLength
CamperBot
@camperbot
Sep 23 2015 14:25
jojokats sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: jojokats already gave blauelf points
Blauelf
@Blauelf
Sep 23 2015 14:25
@Paulie-P You uppercase the whole word, you should uppercase only the first letter.
Paulie
@Paulie-P
Sep 23 2015 14:26
Im not quite sure how to do that
How do I identify the first letter of each element in the array?
Blauelf
@Blauelf
Sep 23 2015 14:26
@Paulie-P Split the word into first letter and rest, and uppercase the first letter, then add those.
Jalita
@UsefulPixels
Sep 23 2015 14:27
@Blauelf I still get the same error message..
Paulie
@Paulie-P
Sep 23 2015 14:27
@Blauelf I'll give it a shot thanks
CamperBot
@camperbot
Sep 23 2015 14:27
paulie-p sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 304 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Sep 23 2015 14:27
You can use val[0] or val.charAt(0) to access the first letter, and val.substring(1) to get everything from the second letter.
@UsefulPixels I understand now, you should have a single line with myRemoved, you accidentally have two.
Aleksander Gębicki
@Takumar
Sep 23 2015 14:33
@Blauelf you are right about @soumyaRauth code but I said about x variable because it is used in 'else' condition and I don't understand what this value set to 1 mean, maybe author tried to prepare a return value?
Blauelf
@Blauelf
Sep 23 2015 14:37
@Takumar I sometimes add similar variables to later output with console.log for debug purposes, and sometimes they are still in the code before the final cleaning. Or it might be the rest of a different approach. Only @soumyaRauth can tell :D
jaredl85
@jaredl85
Sep 23 2015 14:40
Hi everyone, I'm having some difficulty with "waypoint: sort arrays with sort". I feel like I have typed the code correctly, but it is apparently incorrect.

var array = ['beta', 'alpha', 'charlie'];
// Only change code below this line.

var array = [1, 3, 2];

array = array.sort();

// Only change code above this line.
(function() {return array;})();

Blauelf
@Blauelf
Sep 23 2015 14:41
@jaredl85 Use proper code formatting with three backticks (```)
Maria
@artlifestyle
Sep 23 2015 14:41
Hello. I am trying to override the text color
jaredl85
@jaredl85
Sep 23 2015 14:41
@Blauelf I'm not sure what you mean...
Blauelf
@Blauelf
Sep 23 2015 14:42
@jaredl85 The second declaration and assignment of array should not be there.
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:42
@artlifestyle where is that exactly I'll try to help
Blauelf
@Blauelf
Sep 23 2015 14:42
help formatting
CamperBot
@camperbot
Sep 23 2015 14:42

: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

```js ⇦ Type 3 backticks, then type js or html 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

:pencil: read more about code formatting on the FCC Wiki

jaredl85
@jaredl85
Sep 23 2015 14:43
var array = ['beta', 'alpha', 'charlie'];
// Only change code below this line.

var array = [1, 3, 2];

array = array.sort();

  // Only change code above this line.
(function() {return array;})();
@Blauelf thanks. :-)
CamperBot
@camperbot
Sep 23 2015 14:43
jaredl85 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 305 | @blauelf | http://www.freecodecamp.com/blauelf
jaredl85
@jaredl85
Sep 23 2015 14:45
@Blauelf hmmm. I deleted the second declaration of array, but no dice.
Blauelf
@Blauelf
Sep 23 2015 14:46
What does your code look like now?
Do you still have the second assignment? The [1, 3, 2] is not part of the original code. And sorting numbers is a completely different task to sorting strings (sort can take a function as an argument).
Maria
@artlifestyle
Sep 23 2015 14:47
Hello. I am getting an error message that doesn't make sense to me. I was supposed to change a text color to orange. It is showing up as orange in the display. What am I missing? And if this is a bug how do I get the proper answer and move forward?
jaredl85
@jaredl85
Sep 23 2015 14:48
var array = ['beta', 'alpha', 'charlie'];
// Only change code below this line.

var array = [1,3,2];
array.sort();

  // Only change code above this line.
(function() {return array;})();
Blauelf
@Blauelf
Sep 23 2015 14:49
@jaredl85 You did not remove the second declaration and assignment but the third assignment.
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:49
Can you paste your code, cause normally you would do color: orange
Blauelf
@Blauelf
Sep 23 2015 14:50
Your only code line between the comments should read array = array.sort();
Maria
@artlifestyle
Sep 23 2015 14:50

1

<style>
2
body {
3
background-color: black;
4
font-family: Monospace;
5
color: green;
6
}
7

8
.pink-text {
9
color: pink;
10
}
11
.blue-text {
12
color: blue;
13
}
14

orange-text {color: brown;}

15
</style>
16

<h1 id="orange-text" class="pink-text blue-text">Hello World!</h1>
17

18

jaredl85
@jaredl85
Sep 23 2015 14:50
@Blauelf thank you, that worked. I feel a little bit special now. :smile:
CamperBot
@camperbot
Sep 23 2015 14:50
jaredl85 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: jaredl85 already gave blauelf points
tringuyenn
@tringuyenn
Sep 23 2015 14:51
for the ziplines "Build a random quote machine" project, how do I make the call to the API?
I have been doing this:
$.post(
"http://api.forismatic.com/api/1.0",
{method: "getQuote", format: "text", lang: "en"},
function(data, status) {
alert(data);
});
and it seems that doesn't work
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:52
try #orange-text {color:brown;}
Maria
@artlifestyle
Sep 23 2015 14:54
@Jojokats It is exercise 49 in HTML
Sasa Popovic
@Zunior
Sep 23 2015 14:55
@joshmccall221 I succeded with challange. had to check if it is "boolean". Thx anyway
CamperBot
@camperbot
Sep 23 2015 14:55
zunior sends brownie points to @joshmccall221 :sparkles: :thumbsup: :sparkles:
:star: 270 | @joshmccall221 | http://www.freecodecamp.com/joshmccall221
Joanna Katsifaraki
@Jojokats
Sep 23 2015 14:56
@artlifestyle #49 says: Create a CSS class called pink-text that gives an element the color pink.
Maria
@artlifestyle
Sep 23 2015 14:57
@Jojokats thank you! I wasn't following the instructions... I called for brown instead of orange when it clearly says change the text orange. Sorry.
CamperBot
@camperbot
Sep 23 2015 14:57
artlifestyle sends brownie points to @jojokats :sparkles: :thumbsup: :sparkles:
:star: 128 | @jojokats | http://www.freecodecamp.com/jojokats
Soumya Rauth
@soumyaRauth
Sep 23 2015 14:58
@Blauelf You are absolutely correct about the x-factor... :)
Tod Duncan
@todduncan
Sep 23 2015 15:03

#146/#31 in Basic Javascript. The goal is to create a random integer using Math.floor. The returned values are always numbers <1 and not integers. The incompleted part is "The random number generated by myFunction should be an integer". What am I missing here? Thanks

var min = 0;
var max = 9;
function myFunction() {
// Make myFunction return a random number between zero and nine instead of a decimal
// Only change code below this line.
Math.floor(Math.random() * (max - min + 1)) + min
return Math.random();
}

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
(function(){return myFunction();})();

CamperBot
@camperbot
Sep 23 2015 15:03
if you want to thank someone, put an @ before their name!
Sasa Popovic
@Zunior
Sep 23 2015 15:04
Does anyone knows hot to use indexOf with array and reduce
function unite(arr1, arr2, arr3) {

  var all = arr1.concat(arr2.concat(arr3));

 all.reduce(function(a, b) {
      if(a.indexOf(b,0)<0) {
        return b.concat(a);
    }
 });

  //return arguments;
}

unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Mohsin Mumtaz
@mohmum
Sep 23 2015 15:08
Can i build first zipline project just by going through waypoints? Or should i complete other courses on sites like Edx and Udacity?
thepang
@thepang
Sep 23 2015 15:09

I have a general question about codepen: If I write a javascript function in the JS editor, how do I call it in the HTML file? I can only seem to be able to call JS functions if I write the function in script element. Is there a way I can import the JS file like: <?cript src="./codepen/code.js" type="text/javascript" charset="utf-8"></script>

or am I missing something else entirely? It looks like I've done something wrong calling the function since I can see the console error: "Uncaught ReferenceError: myFunction is not defined"

Thank you for the help

CamperBot
@camperbot
Sep 23 2015 15:09
if you want to thank someone, put an @ before their name!
Mohsin Mumtaz
@mohmum
Sep 23 2015 15:10
@camperbot Can i build first zipline project just by going through waypoints? Or should i complete other courses on sites like Edx and Udacity?
Aleksander Gębicki
@Takumar
Sep 23 2015 15:11
@todduncan You have in your code such statement: Math.floor(Math.random() * (max - min + 1)) + min. You need to place the result of this statement in any variable and then return it instead of returning Math.random() like you do now!
@todduncan now you calculate correct value but you don't do anything with it. Check this:
var result = Math.floor(Math.random() * (max - min + 1)) + min;
return result;
Mateja Trifunovski
@Matko95
Sep 23 2015 15:13
@thepang you only need to include jquery or any other frameworks you use
@thepang just follow the guide on the ziplines
Tod Duncan
@todduncan
Sep 23 2015 15:14
@Takumar Thank you. This makes sense now.
Aleksander Gębicki
@Takumar
Sep 23 2015 15:15
@todduncan You're welcome.
thepang
@thepang
Sep 23 2015 15:16
@Matko95 I cannot create my own JS functions and then call it in HTML file?
I am not trying to use existing framework functionality in jquery or the like
Mateja Trifunovski
@Matko95
Sep 23 2015 15:17
@thepang yes, you can, could you show me your codepen?
Justin
@Justintlai
Sep 23 2015 15:19
First time poster - I think i'm stuck on a very simple problem - how do i create a property engines?
var Car = function() {
   this.wheels = 4;
};

// Only change code below this line.
var myCar = new Car();

//Add the property "engines" to myCar, and make it a number.
this.engines = 1;`
Blauelf
@Blauelf
Sep 23 2015 15:20
Just assign anything to myCar.engines.
Aleksander Gębicki
@Takumar
Sep 23 2015 15:20
Hello @Justintlai in JavaScript you create engines just like wheels :-)
Justin
@Justintlai
Sep 23 2015 15:21
@Blauelf that doesnt work :(
Mateja Trifunovski
@Matko95
Sep 23 2015 15:21
@Justintlai You must asign a number
Aaron Peazzoni
@peazzoni1
Sep 23 2015 15:21
Has anyone found a way to use recursion in the Bonfire: Sum all Primes? It also seems like you can't define separate functions in the FCC code editor?
Blauelf
@Blauelf
Sep 23 2015 15:21
@Justintlai You replaced this.engines in your code by myCar.engines?
Justin
@Justintlai
Sep 23 2015 15:22
this is what i typed in my code and it gives me an error saying "no user tests were run"
mycar.engines = 1;
Aleksander Gębicki
@Takumar
Sep 23 2015 15:22
@Justintlai this is accessible in your function not outside.
Brad Wight
@bwarfson
Sep 23 2015 15:23
@Justintlai The car object has already been created so you need to use the myCar object to add a property.
Blauelf
@Blauelf
Sep 23 2015 15:24
@Justintlai Remember that JavaScript is case-sensitive. mycar is not the same as myCar. You could have both variables for full confusion ;)
Aleksander Gębicki
@Takumar
Sep 23 2015 15:24
@Justintlai In your code you have myCar object and then you write mycar.engines = 1;
Mateja Trifunovski
@Matko95
Sep 23 2015 15:24
@Justintlai could you post your full code?
Justin
@Justintlai
Sep 23 2015 15:25
@Blauelf Awesome! Still getting used to camel casing
thanks everyone!!
CamperBot
@camperbot
Sep 23 2015 15:25
if you want to thank someone, put an @ before their name!
mhm
@mierea
Sep 23 2015 15:27
hello guys
I am calling .filter() inside a function that receives as a param an array and some args. How can I pass the args to the .filter() method?
Blauelf
@Blauelf
Sep 23 2015 15:28
You mean to the argument of the filter method?
Aleksander Gębicki
@Takumar
Sep 23 2015 15:28
@mierea you have to call filter method on the array itself: resultOfFiltering = myArr.filter()
Blauelf
@Blauelf
Sep 23 2015 15:29
You can reference arguments of the outer function in an inner function without any passing, if that's what you mean.
mhm
@mierea
Sep 23 2015 15:29
hmm i wil ltry it out
thank you both @Takumar and @Blauelf
CamperBot
@camperbot
Sep 23 2015 15:29
mierea sends brownie points to @takumar and @blauelf :sparkles: :thumbsup: :sparkles:
:star: 345 | @takumar | http://www.freecodecamp.com/takumar
:star: 306 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Sep 23 2015 15:32

An example of using parameters of an outer function in the inner function:

function onlyinrange(arr, arg1, arg2) {
  return arr.filter(function(x) {
    return arg1<=x && x<=arg2;
  });
}
console.log(onlyinrange([1,3,7,4],2,5));

If the decision function were not an inner function, you could use an inner function as a wrapper, or use .bind().

mhm
@mierea
Sep 23 2015 15:33
hmm thats cool and what i was looking for
thanks again @Blauelf
CamperBot
@camperbot
Sep 23 2015 15:33
mierea sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: mierea already gave blauelf points
mhm
@mierea
Sep 23 2015 15:50
ok it seems i need help with bonfire-where-do-i-belong
CamperBot
@camperbot
Sep 23 2015 15:50
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
mhm
@mierea
Sep 23 2015 15:50
although the results returned are correct
the assertions fail
is it a bug or?
Graham Whitley
@lotusgraham
Sep 23 2015 15:50
bonfire factorialize a number
CamperBot
@camperbot
Sep 23 2015 15:50

:fire:Bonfire: Factorialize a Number :link:

function factorialize(num) {
  return num;
}

factorialize(5);

Return the factorial of the provided integer.

more info:  bf details | bf links | hint

Graham Whitley
@lotusgraham
Sep 23 2015 15:50
hint
CamperBot
@camperbot
Sep 23 2015 15:50
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
mhm
@mierea
Sep 23 2015 15:51
bonfire where-do-i-belong
CamperBot
@camperbot
Sep 23 2015 15:51

:fire:Bonfire: Where do I belong :link:

function where(arr, num) {
  // Find my place in this sorted array.
  return num;
}

where([40, 60], 50);

Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).

more info:  bf details | bf links | hint

mhm
@mierea
Sep 23 2015 15:51
bf hint
CamperBot
@camperbot
Sep 23 2015 15:51
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
mhm
@mierea
Sep 23 2015 15:52
hmm am i allowed to paste my code here? maybe someone can see a mistake?
tva10
@tva10
Sep 23 2015 15:55
@mierea maybe I will found mistake...
Blauelf
@Blauelf
Sep 23 2015 15:55
Post your code and we will see.
mhm
@mierea
Sep 23 2015 15:55

``` function where(arr, num) {
// Find my place in this sorted array.
arr.push(num);
console.log(arr.sort());
console.log(arr.indexOf(num));
return arr.indexOf(num);
}

where([10, 20, 30, 40, 50], 35);

ops
Blauelf
@Blauelf
Sep 23 2015 15:56
help formatting
CamperBot
@camperbot
Sep 23 2015 15:56

: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

```js ⇦ Type 3 backticks, then type js or html 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

:pencil: read more about code formatting on the FCC Wiki

mhm
@mierea
Sep 23 2015 15:56
function where(arr, num) {
  // Find my place in this sorted array.
  arr.push(num);
  console.log(arr.sort());
  console.log(arr.indexOf(num));
  return arr.indexOf(num);
}

where([10, 20, 30, 40, 50], 35);
tva10
@tva10
Sep 23 2015 15:57
@mierea If I know this sort() function works as with string? isn't it?
mhm
@mierea
Sep 23 2015 15:57
@tva10 it can also sort numeric values
tva10
@tva10
Sep 23 2015 15:57
or nope...
mhm
@mierea
Sep 23 2015 15:58
this is weird
so if i change the values
when calling the where function
on the left side of the screen
Blauelf
@Blauelf
Sep 23 2015 15:58
sort() can sort numeric values if you give it a comparison function as a parameter. Something like sort((a,b)=>a-b)
mhm
@mierea
Sep 23 2015 15:58
i see the correct index
tva10
@tva10
Sep 23 2015 15:59
@Blauelf this is Es6 notation?
Blauelf
@Blauelf
Sep 23 2015 15:59
Works without if all your numbers have the same amount of digits.
mhm
@mierea
Sep 23 2015 15:59
ok...
but i still do not understand one thing
tva10
@tva10
Sep 23 2015 15:59
@Blauelf or it will be like this sort(function(a,b){return a-b;})
Blauelf
@Blauelf
Sep 23 2015 15:59
@tva10 Yes, you could write sort(function(a,b){return a-b}) instead.
mhm
@mierea
Sep 23 2015 16:00
the challenge is checking assert(where([10, 20, 30, 40, 50], 35) === 3, '[10, 20, 30, 40, 50], 35 should return 3.');[10, 20, 30, 40, 50], 35 should return 3.
in the small debugger there
i see the correct value
yet the assert fails
Blauelf
@Blauelf
Sep 23 2015 16:01
Did you check which of the asserts fail?
mhm
@mierea
Sep 23 2015 16:02
hmm i think something was wrong on my browser
in any case you are also right about the sort function
after clearing cache i saw that only one asserts was failing
and it was because of the sort not having the condition
thank you @Blauelf
CamperBot
@camperbot
Sep 23 2015 16:03
mierea sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: mierea already gave blauelf points
tva10
@tva10
Sep 23 2015 16:03
@mierea may be it fails on where([5, 3, 20, 3], 3)??
@mierea it is because string sort()
mhm
@mierea
Sep 23 2015 16:04
first it was failing all (cache issue maybe?) after clearing that yes. so i sorted for numeric.
Blauelf
@Blauelf
Sep 23 2015 16:04
With sort(), numbers are converted to strings and compared that way.
mhm
@mierea
Sep 23 2015 16:05
i have to admit. js is really hard lol
tva10
@tva10
Sep 23 2015 16:05
@mierea nope
mhm
@mierea
Sep 23 2015 16:05
took me quite some hours to finish the bonfire section
tva10
@tva10
Sep 23 2015 16:05
try clear cash and reset task...
@mierea because this was work on my page
 sorted array.
  arr.push(num);
  arr.sort((a,b)=>a-b);

  return arr.indexOf(num);
and Es6 notation works too
@Blauelf thanks for this example :D
CamperBot
@camperbot
Sep 23 2015 16:07
tva10 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 307 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Sep 23 2015 16:07
One can also use reduce to solve this one, simply count the elements that are less than num ;)
function where(arr, num) {
  return arr.reduce((a,b)=>a+(b<num),0);
}
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:07
How do you return undefined....just > return undefined; ??
tva10
@tva10
Sep 23 2015 16:08
@Blauelf mmm es6 <3
I need read more about that
Blauelf
@Blauelf
Sep 23 2015 16:09
Arrow functions are great for those small helper functions. There they increase readability. On other places... (I wrote a lot of cryptic code with them ;))
@TheHighPriestess return undefined; works, but return; or ending the function without returning anything should work as well.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:11
@Blauelf Thanks. That's what I thought.
CamperBot
@camperbot
Sep 23 2015 16:11
thehighpriestess sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 308 | @blauelf | http://www.freecodecamp.com/blauelf
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:11
how do u end a function without returning anything?
Blauelf
@Blauelf
Sep 23 2015 16:14
Don't execute a return statement.
Sean Campbell
@natac13
Sep 23 2015 16:14
@thehighpriestess meaning what like you want to force exit the function or just have the function end?
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:14
@natac13 yeah
Blauelf
@Blauelf
Sep 23 2015 16:15
That's what return; is for. Exit the function without returning anything.
Sean Campbell
@natac13
Sep 23 2015 16:15
@blauelf arrow functions have a lot to them with regard to changing this to a lexical-this
Blauelf
@Blauelf
Sep 23 2015 16:16
Something like function greet(name) {console.log("Hello "+name+"!");} does not have a return statement, so returns undefined.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:16
@Blauelf oh ok....
Sean Campbell
@natac13
Sep 23 2015 16:16
The scope and closure book from you don't know js by kyle Simpson explains about it in chapter 5 I believe
Blauelf
@Blauelf
Sep 23 2015 16:17
@natac13 Which is ok if you know about it.
Sean Campbell
@natac13
Sep 23 2015 16:17
You bet!
Harsh Kumar
@hkumar1993
Sep 23 2015 16:17
hi guys
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:17
I'm trying to use isNaN to verify that both arguments are numbers...and I see that it thinks "3" is a number.
tva10
@tva10
Sep 23 2015 16:17
@hkumar1993 Hello
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:17
Is there a better way to do it?
Blauelf
@Blauelf
Sep 23 2015 16:17
Sure, it is. In the JavaScript sense.
Harsh Kumar
@hkumar1993
Sep 23 2015 16:18
i've got a question about challenge 174
Sean Campbell
@natac13
Sep 23 2015 16:18
It using coercion to change the type @thehighpriestess
Harsh Kumar
@hkumar1993
Sep 23 2015 16:18
in Javascript, reversing a string
i mean, ive made the function
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:18
@natac13 Yeah. I'm trying to find the best way to check if both arguments are numbers.
Blauelf
@Blauelf
Sep 23 2015 16:19
I think something like typeof arg1 === "number" should work here.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:19
Any ideas?
@Blauelf I initially tried that....I will have to go back to it, I guess
Harsh Kumar
@hkumar1993
Sep 23 2015 16:19
but I don't know what else the challenge is asking for, does it want me to run the function 3 times ? (because that actually doesnt work lol)
Sean Campbell
@natac13
Sep 23 2015 16:19
Try typeof
Blauelf
@Blauelf
Sep 23 2015 16:20
@hkumar1993 Post your code
tva10
@tva10
Sep 23 2015 16:20
@hkumar1993 you need to reverse a string? yes?
Sean Campbell
@natac13
Sep 23 2015 16:20
Help formatting
CamperBot
@camperbot
Sep 23 2015 16:20

: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

```js ⇦ Type 3 backticks, then type js or html 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

:pencil: read more about code formatting on the FCC Wiki

tva10
@tva10
Sep 23 2015 16:21
because this is one line task...
Blauelf
@Blauelf
Sep 23 2015 16:21
Could be done in several ways. As always, it can be done with reduce(). :P
Harsh Kumar
@hkumar1993
Sep 23 2015 16:22
function reverseString(str,delim) {

  var array = str.split(delim);
  array = array.reverse();
  str = array.join(delim);

  return str;
}

reverseString("hello","");
reverseString("Howdy","");
reverseString("Greetings from Earth","");
Sean Campbell
@natac13
Sep 23 2015 16:22
@tva10 for most beginners I don't think it is wise to go with a one line solution just mho
tva10
@tva10
Sep 23 2015 16:23
@hkumar1993 I think that test cases doesn't write second argument
Blauelf
@Blauelf
Sep 23 2015 16:23
@hkumar1993 There is no "delim" in the testing code. You might define a default value for it or define it as a variable.
tva10
@tva10
Sep 23 2015 16:23
@hkumar1993 and you need to write it by yourself there...
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:23
@Blauelf @natac13 It does the same thing with typeof. It says that "3" is a number
Blauelf
@Blauelf
Sep 23 2015 16:24
@TheHighPriestess Have you tried on your local console? Are you sure you ask for typeof "3"?
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:24
oh..excuse me...
Sean Campbell
@natac13
Sep 23 2015 16:24
typeof "3" === "number"
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:24
that is very incorrect
tva10
@tva10
Sep 23 2015 16:24
@natac13 what means mho??
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:24
my mistake
Sean Campbell
@natac13
Sep 23 2015 16:24
My humble opinion
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:24
@Blauelf yeah....I just caught my error.
tva10
@tva10
Sep 23 2015 16:25
@natac13 okay thanks
Harsh Kumar
@hkumar1993
Sep 23 2015 16:25
sorry, i come from a C++ background so i assumed when declaring the function i could put the variable name as i wish
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:25
I need to take care when I copy and paste code...to change variable names
Harsh Kumar
@hkumar1993
Sep 23 2015 16:25
the original code had
reverseString("hello","");
so i assumed need to put my own second argument
tva10
@tva10
Sep 23 2015 16:26
@hkumar1993 but testcases had (reverseString("Howdy")
Harsh Kumar
@hkumar1993
Sep 23 2015 16:26
ah yes i just noticed that
and tried it too
it worked
thanks :smile:
CamperBot
@camperbot
Sep 23 2015 16:27
if you want to thank someone, put an @ before their name!
Harsh Kumar
@hkumar1993
Sep 23 2015 16:29
thanks @tva10
CamperBot
@camperbot
Sep 23 2015 16:29
hkumar1993 sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:star: 245 | @tva10 | http://www.freecodecamp.com/tva10
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:32
In the bonfires....it's OK to write an additional function?
Master Builder
@McGowanC
Sep 23 2015 16:32
yes
Rex Schrader
@SaintPeter
Sep 23 2015 16:32
@TheHighPriestess Yes, I did that a bunch
@TheHighPriestess For improved code clarity.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:33
@SaintPeter Ok thanks...because I see that "Arguments optional" says: "Every time you deal with an argument, you have to check if it is a number or not. For this a function that handles this task will save you repeated code."
CamperBot
@camperbot
Sep 23 2015 16:33
thehighpriestess sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 695 | @saintpeter | http://www.freecodecamp.com/saintpeter
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:33
so...I put that code in another function
Rex Schrader
@SaintPeter
Sep 23 2015 16:34
Sounds like a good plan
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:37
@SaintPeter but....the the "return undefined" just returns to the calling function
instead of terminating
What if I want the whole thing to stop...if I call the number check function and find out that one of the arguments isn't a number?
I can't use "return undefined"
because that just sends it back to the calling function
or is that how it's done....if it comes back undefined...then the function from which it was called needs to return it undefined?
Rex Schrader
@SaintPeter
Sep 23 2015 16:39
@TheHighPriestess You need to test the result of your return function. I'm not sure how much having a function do it for you is helping.
if(typeof num !== 'number') {
   return function(num) {
         //stuff
   }
} else {
   return num + // whatever
}
@TheHighPriestess It needs to return a function.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:40
let me show you what I have
function add() {

    arg1 =  arguments[0];
    arg2 =  arguments[1];
    numberCheck(arg1,arg2);



    console.log("he");



}

add("http://bit.ly/IqT6zt");


function numberCheck(arg1,arg2){
    if (typeof arg1 !== "number" || typeof arg2 !== "number") {
            console.log("One or more of your arguments is not a number.");
            return undefined;
        }
        else {
            console.log("Both arguments are numbers.");

        }
}
I don't see any reason to have that in a separate function but...let's say that I wanted to do it this way..
if numberCheck receives at least one argument that's not a number...I don't want it to go back to the calling function
it should exit
stop
Rex Schrader
@SaintPeter
Sep 23 2015 16:43
@TheHighPriestess ok, there are 4 possible conditions:
1) arg1 and arg2 are both numbers - return the sum
2) arg1 is a number, arg2 is not - return a function
3) arg1 is not a number, arg2 is a number - return undefined
4) arg1 is not a number, arg2 is not a number - return undefined
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:44
from the instuctions it looks like it only returns a function if it has one argument
Rex Schrader
@SaintPeter
Sep 23 2015 16:44
@TheHighPriestess I don't know how much value there is in seperating those out. You could write a function called isNum:
function isNum(num) {
   return typeof num === 'number';
}
@TheHighPriestess Yes, if arg2 is "not a number", IE: undefined, return a function
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:45
and if the function receives only ONE argument...then have it return a function
but if it receives one argument..this check doesn't work
Rex Schrader
@SaintPeter
Sep 23 2015 16:47
@TheHighPriestess Yes, arg2 the param will be 'undefined', so isNum would return false.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:47
so...this function is not going to do the trick
Rex Schrader
@SaintPeter
Sep 23 2015 16:48
Your function, as written, will not.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:49
it should only be called if arguments.length = 2
i don't know if i'm going about this in the right way
Rex Schrader
@SaintPeter
Sep 23 2015 16:52
@TheHighPriestess How about:
function add() {
 arg1 = arguments[0];
 arg2 = arguements[1]; 

 if(isNum(arg1) && isNum(arg2)) {
    // add
 } else if(isNum(arg1) && !isNum(arg2)) {
   // return function
 } else if(!isNum(arg1)) {
   // return undefined
 }
}
function isNum(num) {
   return typeof num === 'number';
}
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:53
isNum?
is that javascript?
Rex Schrader
@SaintPeter
Sep 23 2015 16:53
@TheHighPriestess Nope, it's a function I just wrote, see above.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:53
oh haha
sorry
Rex Schrader
@SaintPeter
Sep 23 2015 16:54
@TheHighPriestess It's a bit easier than having those typeof arg1 === 'number' all over the place
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:54
ok...so the function isNum returns either true or false
and then they are compared
Rex Schrader
@SaintPeter
Sep 23 2015 16:54
@TheHighPriestess Correct.
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:54
very nice :)
@SaintPeter thank you
CamperBot
@camperbot
Sep 23 2015 16:54
thehighpriestess sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: thehighpriestess already gave saintpeter points
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 16:55
Very easy to understand...very clear.
I wish I would have thought of it LOL
oh well...I'm learning
@SaintPeter It still needs one more check though..does it not?
what bout...if arg1 isn't a number and arg2 is?
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 17:01
couldn't one just put an || there and do the opposite on the other side?
Rex Schrader
@SaintPeter
Sep 23 2015 17:02
@TheHighPriestess "If either argument isn't a valid number, return undefined."
Since all of the other cases are already covered, it doesn't matter if arg2 is valid or not at that point, having an invalid arg1 always returns undefined
Think about it: arg1 and arg2 are numbers, add, arg1 is defined, arg2 is undefined, retrun the function. In any other case arg1 is undefined, it doesn't matter what arg2 is because you can't DO anything with an undefined arg1
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 17:04
yes...you're right
got it
@SaintPeter thank you
CamperBot
@camperbot
Sep 23 2015 17:05
thehighpriestess sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: thehighpriestess already gave saintpeter points
Rex Schrader
@SaintPeter
Sep 23 2015 17:06
@TheHighPriestess One of these days I'll invent "super brownie points" so I can get them after I've gotten them. ;)
Michael Kallies
@mkallies
Sep 23 2015 17:08
hint seek and destroy
CamperBot
@camperbot
Sep 23 2015 17:08
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Avil
@Avil172
Sep 23 2015 17:10

hi
i am learning bootstrap,
these two exercises..

http://freecodecamp.com/challenges/waypoint-create-a-block-element-bootstrap-button
http://freecodecamp.com/challenges/waypoint-taste-the-bootstrap-button-color-rainbow

state that btn-block needs btn, and btn-primary needs both btn and btn-block, but i tried to use btn-block and btn-primary alone, and they both seem to work without any of the other classes. so can anyone explain to me what's wrong in using them alone?

Rex Schrader
@SaintPeter
Sep 23 2015 17:12
@Avil172 You always need btn, then a color, such as btn-default or btn-primary - then btn-block changes the behavior to make them a block.
Avil
@Avil172
Sep 23 2015 17:14
@SaintPeter thanks for the reply.
yeah, but i was able to use btn-block alone(doing so doesn't complete the exercise though)
CamperBot
@camperbot
Sep 23 2015 17:14
avil172 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 696 | @saintpeter | http://www.freecodecamp.com/saintpeter
Avil
@Avil172
Sep 23 2015 17:15
@SaintPeter but using "btn btn-block" and "btn-block", they looked a bit different.
Rex Schrader
@SaintPeter
Sep 23 2015 17:15
@Avil172 Just because it completes the exercies doesn't mean it's right. The test code is limitted in the number and type of errors it can detect.
@Avil172 The bootstrap spec says "always use btn for buttons"
Avil
@Avil172
Sep 23 2015 17:17
@SaintPeter no, i mean, doing something different(other than what's written in the exercise, ie using btn-block alone) didn't let me complete the challenge, but i could see the output.
Rex Schrader
@SaintPeter
Sep 23 2015 17:18
@Avil172 Well, sure, the output is governed by bootstrap. It'll display what you tell it. If the exercise passes or not is a function of the test cases.
Avil
@Avil172
Sep 23 2015 17:19
@SaintPeter so i'll have to always use btn whenever i use buttons.. hmm..got it
thanks.
CamperBot
@camperbot
Sep 23 2015 17:19
avil172 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: avil172 already gave saintpeter points
Rex Schrader
@SaintPeter
Sep 23 2015 17:19
@Avil172 :D
Pete McPherson
@StartupDino
Sep 23 2015 17:19

Anyone know anything about mobile IP addresses?
I made a "NO BS WEATHER APP" for my zipline.

Seems to work fine pulling my coords on a desktop, but the mobile version is doing something funky.

Any ideas?

http://codepen.io/StartupDino/full/qONvLp/

debruinjules
@debruinjules
Sep 23 2015 17:21
wiki Bonfire: Factorialize a Number
CamperBot
@camperbot
Sep 23 2015 17:21

:point_right: bonfire factorialize a number [wiki]

The problem

Return the factorial of the provided integer. If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.

Factorials are often represented with the shorthand notation n!

For example: 5! = 1 * 2 * 3 * 4 * 5 = 120f

:pencil: read more about bonfire factorialize a number on the FCC Wiki

Chris
@Shifthawke
Sep 23 2015 17:22
Can someone answer something about boolean for me?
Does FCC go further into what all of this means, or what each part is?
if(typeof(myFirstName) !== "undefined" && typeof(myLastName) !== "undefined"){(function(){return myFirstName + ', ' + myLastName;})();}
Rex Schrader
@SaintPeter
Sep 23 2015 17:23
@StartupDino IP address lookup is inherently chancy and weird. You can try the geolocaiton API of the browser which should work better with mobile. Use IP address lookup as a backup
Leinadryan
@leinadryan
Sep 23 2015 17:23
wiki Bonfire: Reverse a String
CamperBot
@camperbot
Sep 23 2015 17:23

:point_right: bonfire reverse a string [wiki]

Problem Explanation:

You need to take the string and reverse it so if you had originally 'hello', it will turn into 'olleh'. Because you will need to split it, you will be working with Arrays too.

:pencil: read more about bonfire reverse a string on the FCC Wiki

Rex Schrader
@SaintPeter
Sep 23 2015 17:23
@Shifthawke What do you need help with? the !== and === operators? or the && operator?
Chris
@Shifthawke
Sep 23 2015 17:23
what does !==
mean
Elizabeth Hatleli
@TheHighPriestess
Sep 23 2015 17:23
@SaintPeter haha
Chris
@Shifthawke
Sep 23 2015 17:24
I know in c++ == is equal
Leinadryan
@leinadryan
Sep 23 2015 17:24
Thanks @Rafase282
CamperBot
@camperbot
Sep 23 2015 17:24
leinadryan sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
Chris
@Shifthawke
Sep 23 2015 17:24
the other ones too lol. ==== &&
CamperBot
@camperbot
Sep 23 2015 17:24
:star: 481 | @rafase282 | http://www.freecodecamp.com/rafase282
Vanesa Villafana Liñan
@DeniseDesu
Sep 23 2015 17:24
it means "not equal"
Rex Schrader
@SaintPeter
Sep 23 2015 17:25
@Shifthawke The ! operator means logical "not". === means "exactly matches, no ifs ands or buts", and !== is the inverse of that.
Pete McPherson
@StartupDino
Sep 23 2015 17:25
thanks @SaintPeter
CamperBot
@camperbot
Sep 23 2015 17:25
startupdino sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 697 | @saintpeter | http://www.freecodecamp.com/saintpeter
Chris
@Shifthawke
Sep 23 2015 17:25
What about &&
Rex Schrader
@SaintPeter
Sep 23 2015 17:25
@Shifthawke && is logical and - meaning it works on true and false values. As opposed to & which is a bitwise and.
Chris
@Shifthawke
Sep 23 2015 17:25
Ah. Thank you.
CamperBot
@camperbot
Sep 23 2015 17:25
if you want to thank someone, put an @ before their name!
Chris
@Shifthawke
Sep 23 2015 17:25
Yes Bob
Thanks @SaintPeter @DeniseDesu
CamperBot
@camperbot
Sep 23 2015 17:26
shifthawke sends brownie points to @saintpeter and @denisedesu :sparkles: :thumbsup: :sparkles:
:star: 698 | @saintpeter | http://www.freecodecamp.com/saintpeter
:star: 210 | @denisedesu | http://www.freecodecamp.com/denisedesu
Rex Schrader
@SaintPeter
Sep 23 2015 17:27
@Shifthawke So . . .
true && false === false
false && true === false
true && true === true
false && false ==== false
Chris
@Shifthawke
Sep 23 2015 17:27
false and false equals false. I don't know what that's funny but it is
I'm writing this down now, thank you. @SaintPeter
CamperBot
@camperbot
Sep 23 2015 17:27
shifthawke sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: shifthawke already gave saintpeter points
debruinjules
@debruinjules
Sep 23 2015 17:37
wiki Bonfire: Check for Palindromes
CamperBot
@camperbot
Sep 23 2015 17:37

:point_right: bonfire check for palindromes [wiki]

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.

:pencil: read more about bonfire check for palindromes on the FCC Wiki

Chris
@Shifthawke
Sep 23 2015 17:37
wiki brownies
CamperBot
@camperbot
Sep 23 2015 17:37
no wiki entry for: brownies
:pencil: click here to create one now!after creating your page type update to reload it here
Chris
@Shifthawke
Sep 23 2015 17:37
wiki brownie
CamperBot
@camperbot
Sep 23 2015 17:37

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

kgoode517
@kgoode517
Sep 23 2015 17:42
what is the difference between str.split('' ) and str.split(' ')?
Chris
@Shifthawke
Sep 23 2015 17:43
wiki str.split
CamperBot
@camperbot
Sep 23 2015 17:43
no wiki entry for: strsplit
:pencil: click here to create one now!after creating your page type update to reload it here
debruinjules
@debruinjules
Sep 23 2015 17:43
wiki Bonfire: Find the Longest Word in a String
CamperBot
@camperbot
Sep 23 2015 17:43

:point_right: bonfire find the longest word in a string [wiki]

Explanation:

You have to go through each word and figure out which one is the longest and return not the word, but how many characters it has.

:pencil: read more about bonfire find the longest word in a string on the FCC Wiki

Rex Schrader
@SaintPeter
Sep 23 2015 17:45
@kgoode517 THe differeence is the empty string ('') breaks every single character in the string, while a space (' ') breaks on spaces in the string.
kgoode517
@kgoode517
Sep 23 2015 17:46
@SaintPeter Thank you !
CamperBot
@camperbot
Sep 23 2015 17:46
kgoode517 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 699 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Sep 23 2015 17:47
@kgoode517 IE:
var str = "I am a string";
str.split(''); // ['I', ' ', 'a', 'm', ' ', 'a',  (and so on)
str.split(' '); // ['I','am','a','string']
kgoode517
@kgoode517
Sep 23 2015 17:47
@SaintPeter that makes pefect sense thank you as always
CamperBot
@camperbot
Sep 23 2015 17:47
kgoode517 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: kgoode517 already gave saintpeter points
Rex Schrader
@SaintPeter
Sep 23 2015 17:47
@kgoode517 :D
debruinjules
@debruinjules
Sep 23 2015 17:51
wiki Bonfire: Title Case a Sentence
CamperBot
@camperbot
Sep 23 2015 17:51

:point_right: bonfire title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about bonfire title case a sentence on the FCC Wiki

Jordan Bourne
@JordanBourne
Sep 23 2015 18:03
Hi, I'm doing one of the bonfires and when I run tests, nothing happens. Any suggestions as to why this might be?
Saad Mehmood
@saadmehmood233
Sep 23 2015 18:04
try refreshing the browser @JordanBourne
Jordan Bourne
@JordanBourne
Sep 23 2015 18:05
I tried, if I intentionally mess up my code I'll get an error, so I'm thinking there's some error somewhere but it's not telling me what it is.
Perhaps you can look at it? Can I just paste it here?
Saad Mehmood
@saadmehmood233
Sep 23 2015 18:06
yes sure
Jordan Bourne
@JordanBourne
Sep 23 2015 18:06

function findLongestWord(str) {
var newStr = str.split(" ");
var i = newStr.length;
var countLength = 0;
var maxLength = 0;
while(i >= 0) {
countLength = newStr.length[i];
if(countLength > maxLength) {
maxLength = countLength;
}
}
return maxLength;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

I don't know how to do the pretty format box with code
Saad Mehmood
@saadmehmood233
Sep 23 2015 18:07
past your code between ```
explain formatting
CamperBot
@camperbot
Sep 23 2015 18:07

: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

```js ⇦ Type 3 backticks, then type js or html 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

:pencil: read more about code formatting on the FCC Wiki

Jordan Bourne
@JordanBourne
Sep 23 2015 18:08

'''js
function findLongestWord(str) {
var newStr = str.split(" ");
var i = newStr.length;
var countLength = 0;
var maxLength = 0;
while(i >= 0) {
countLength = newStr.length[i];
if(countLength > maxLength) {
maxLength = countLength;
}
}
return maxLength;
}

findLongestWord("The quick brown fox jumped over the lazy dog");