These are chat archives for FreeCodeCamp/Help

3rd
Aug 2015
Juan Martínez
@jbmartinez
Aug 03 2015 00:00
@Feners4 inside addData, change $scope.getdata to a new variable, push the transformed elements to it and return it
Juan Martínez
@jbmartinez
Aug 03 2015 00:07
@Feners4 I gotta go, good luck!
Feners4
@Feners4
Aug 03 2015 00:07
@jbmartinez thx!
jds11235
@jds11235
Aug 03 2015 00:33
has anyone here done the twitch api campfire?
Logan Tegman
@ltegman
Aug 03 2015 00:39
@jds11235 Sure have, what’s up?
Lightwaves
@Lightwaves
Aug 03 2015 00:41
I'm curious if a picture like this would have helped anyone with the bonfire map the debris
jds11235
@jds11235
Aug 03 2015 00:41
I'm having difficulties with the $.getJSON, my web debugger says XMLHttpRequest cannot load https://api.twitch.tv/kraken/streams/beohoff. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access. for every name
Lightwaves
@Lightwaves
Aug 03 2015 00:41
blob
I had to use a latest us raster creation techniques to make it
"cough" paint "cough"
well that along with a description of the semi major axis
Logan Tegman
@ltegman
Aug 03 2015 00:43
@jds11235 You have to make a jsonp request to get past the same-origin policy. One way to do so is to just add ?callback=? to your request, but the Jquery docs list a couple different ways.
jds11235
@jds11235
Aug 03 2015 00:45
@ltegman thanks, is there a reason why it is necessary for twitch while it has not been necessary for other APIs?
Logan Tegman
@ltegman
Aug 03 2015 00:47
@jds11235 Hmmm, I couldn’t say. I’ve had to do it with every API I access on Codepen, so I just thought it was a Codepen thing!
Feners4
@Feners4
Aug 03 2015 00:49
@ltegman I'm stuck in the same zipline.. could you help me with why I'm getting null in my display... http://codepen.io/Feners4/pen/EjONEe
Alan Savage
@asavage111
Aug 03 2015 01:07
hello all. I am working on Waypoint: Override Styles with Important and I can't figure out why I cant get this to work.
blob
Logan Tegman
@ltegman
Aug 03 2015 01:08
@Feners4 I think the problem is that you’re doing a map function that assigns to $scope.getData but doesn’t return anything, so $scope.getData starts out as an array with null elements for as many users as you have and then you push any valid users onto the end of that in your addData function.
Alan Savage
@asavage111
Aug 03 2015 01:09
How did you post the screen post to take up the entire screen?
jds11235
@jds11235
Aug 03 2015 01:11
@asavage111 instead of putting each classes in single quotes put them all in single quotes separated by spaces (eg with only one set of single quotes)
Feners4
@Feners4
Aug 03 2015 01:12
@ltegman so how can I fix this?..
Alan Savage
@asavage111
Aug 03 2015 01:12
@jds11235 Thanks!
dc
@dcsan
Aug 03 2015 01:12
@ltegman thats a codepen embed
Logan Tegman
@ltegman
Aug 03 2015 01:16
@Feners4 I would just do the map function and not assign it to anything, since your addData function is going to push to the getData variable anyways.
Rémi Fortier
@mizujin
Aug 03 2015 01:23
Hello, could anybody help me out with Learnyounode - > Juggling Async ?
dc
@dcsan
Aug 03 2015 01:23
is that a bonfire?
Feners4
@Feners4
Aug 03 2015 01:24
@ltegman i made getdata an empty array, however it displays an empty array instead of an the array filled with users..
Rémi Fortier
@mizujin
Aug 03 2015 01:24
@dcsan no, it's all part of the MEAN stack part of freecodecamp, specifically node.js
Moisés Man
@moigithub
Aug 03 2015 01:46
$q angular promises seems difficult to understand...
Alex Labanino
@labanino
Aug 03 2015 01:53
Hey guys! I just started the Bonfire's and I'm working online. So my question is, Why do I need to clone the FCC repo? Thanks.
M Used
@mildused
Aug 03 2015 01:56
@labanino You don't?
dc
@dcsan
Aug 03 2015 01:56
which bonfire are you on?
CamperBot
@camperbot
Aug 03 2015 01:56
type bonfire name
to get some info on that bonfire here
dc
@dcsan
Aug 03 2015 01:56
@labanino
bonfire name
CamperBot
@camperbot
Aug 03 2015 01:58
no, type part of the name of the bonfire! eg bonfire roman
dc
@dcsan
Aug 03 2015 01:59
bonfire roman
CamperBot
@camperbot
Aug 03 2015 01:59

:fire:Bonfire: Roman Numeral Converter :link:

function convert(num) {
 return num;
}

convert(36);

Convert the given number into a roman numeral.

for more info: bf details bf links bf script bf wiki bf spoiler

dc
@dcsan
Aug 03 2015 01:59
bf details
CamperBot
@camperbot
Aug 03 2015 01:59

:fire:Bonfire: Roman Numeral Converter :link:

function convert(num) {
 return num;
}

convert(36);

Convert the given number into a roman numeral.
All <a href="http://www.mathsisfun.com/roman-numerals.html">roman numerals</a> answers should be provided in upper-case.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Array.splice()),
Array.indexOf()),
Array.join())


  • bonfire info for more info
  • bonfire links
  • bonfire script for the script
  • bonfire spoiler for some clues on how to solve it
  • bonfire wiki for related info from the wiki
Jakob Dahl
@saadanerdetbare
Aug 03 2015 01:59
@labanino you need to clone the repo if you want to get involved in working on the site
not for solving bonfires
Rémi Fortier
@mizujin
Aug 03 2015 02:01
Is there any great book for Node.js that really take you by the hand ? I had to read a lot about blocking, non-blocking, socket, server, etc. I know this is mandatory but I never worked with any server
M Used
@mildused
Aug 03 2015 02:05
@mizujin I'm looking for one too. Most tend to teach how to do specific examples, I want to learn why rather than how. Those tutorials are mostly just typing the code that you see...
Rémi Fortier
@mizujin
Aug 03 2015 02:05
@mildused I feel exactly the same. They all assume you know the server stuff, but I don't
just started FCC 2 months ago and i'm now in node/angular. You can't assume all students to know stuff like that
I would have liked some pointers/explanatations on this beforehand
that and how you use callbacks for non-blocking stuff in node.js
Kevin Agpaoa
@agpaoak
Aug 03 2015 02:32
any hints or tips for sorted union, basic algorithm scripting: bonfire #27
CamperBot
@camperbot
Aug 03 2015 02:32
type bonfire name
to get some info on that bonfire here
Marc Davenport
@oneate7
Aug 03 2015 02:33
Is there anyone around who has completed the Exact Change Bonfire?
Marc Davenport
@oneate7
Aug 03 2015 02:41
bonfire exact change
CamperBot
@camperbot
Aug 03 2015 02:41
can't find a bonfire called exact change
Lightwaves
@Lightwaves
Aug 03 2015 02:42
bonfire Exact Change
CamperBot
@camperbot
Aug 03 2015 02:42
can't find a bonfire called exact change
Lightwaves
@Lightwaves
Aug 03 2015 02:42
lol hmm
Marc Davenport
@oneate7
Aug 03 2015 02:42
bonfire exact
CamperBot
@camperbot
Aug 03 2015 02:42
can't find a bonfire called exact
dc
@dcsan
Aug 03 2015 02:42
hmm maybe thats a more advanced one
Marc Davenport
@oneate7
Aug 03 2015 02:42
It hates me, lol
Lightwaves
@Lightwaves
Aug 03 2015 02:42
haha it doesn't like me either
dc
@dcsan
Aug 03 2015 02:43
ah its under algorithms. OK i'll fix it in a bit!
only have the basics so far like
bf false
CamperBot
@camperbot
Aug 03 2015 02:43

:fire:Bonfire: Falsey Bouncer :link:

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr;
}

bouncer([7, 'ate', '', false, 9]);

Remove all falsey values from an array.

for more info: bf details bf links bf script bf wiki bf spoiler

dc
@dcsan
Aug 03 2015 02:43
bf optional
CamperBot
@camperbot
Aug 03 2015 02:43

:fire:Bonfire: Arguments Optional :link:

function add() {
  return false;
}

add(2,3);

Create a function that sums two arguments together. If only one argument is provided, return a function that expects one additional argument and will return the sum.

for more info: bf details bf links bf script bf wiki bf spoiler

dc
@dcsan
Aug 03 2015 02:43
i'll get to the rest later today
Marc Davenport
@oneate7
Aug 03 2015 02:45
Ah, ok. No worries. Very cool bot, btw.
dc
@dcsan
Aug 03 2015 02:45
tx. more coming!
about @oneate7
CamperBot
@camperbot
Aug 03 2015 02:45
oneate7 oneate7
:star: 1 no bio set
this feature is linked to our beta site, so it may not have all users til we go live with the new release.
dc
@dcsan
Aug 03 2015 02:45
thanks @oneate7
CamperBot
@camperbot
Aug 03 2015 02:45
dcsan sends karma to oneate7 :thumbsup: :sparkles: :sparkles:
dc
@dcsan
Aug 03 2015 02:45
about @oneate7
CamperBot
@camperbot
Aug 03 2015 02:45
oneate7 oneate7
:star: 1 no bio set
this feature is linked to our beta site, so it may not have all users til we go live with the new release.
dc
@dcsan
Aug 03 2015 02:46
karma sending is disabled until we go live with the new beta site
Marc Davenport
@oneate7
Aug 03 2015 02:46
Ah yeah... I remember you talking about that during the Twitch stream.
That'll be nice to have, especially for those folks that are constantly helping out.
dc
@dcsan
Aug 03 2015 02:47
yes, the same questions come up a lot
explain immu
CamperBot
@camperbot
Aug 03 2015 02:47

:pencil: js immutable

Immutable means you can't change
Javascript has lots of immutable types. Try this in your console.

s="red"
s[1]  // "e"
s[1]="x"
s // "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

dc
@dcsan
Aug 03 2015 02:47
find js
CamperBot
@camperbot
Aug 03 2015 02:47
dc
@dcsan
Aug 03 2015 02:47
but we still need to add a lot more content
the wiki is hooked in and running but it's pretty thin at the moment
explain example
CamperBot
@camperbot
Aug 03 2015 02:47

:pencil: example

This is an example wiki entry. Break it up with a ## H2 heading as content up that will show in the chat, but the rest is on the wiki.

console.log("less is more!");
HappyCamping -{ Happy Camping! :+1: }
https://github.com/camperbot

:pencil: read more about example on the FCC Wiki

Lightwaves
@Lightwaves
Aug 03 2015 02:47
hmm this is pretty interesting.
Huh looks like me and evaristoc might have our work cut out for us
dc
@dcsan
Aug 03 2015 02:48
about @Lightwaves
CamperBot
@camperbot
Aug 03 2015 02:48
lightwaves lightwaves
:star: 128 no bio set
this feature is linked to our beta site, so it may not have all users til we go live with the new release.
Lightwaves
@Lightwaves
Aug 03 2015 02:48
that is really cool!
dc
@dcsan
Aug 03 2015 02:48
oops. default size isn't working. i wonder if that's an SVG file
you should be able to scale ppl's avatar images
Lightwaves
@Lightwaves
Aug 03 2015 02:49
it's the default image I never bothered to upload it
img
Jason Blacker
@flossless
Aug 03 2015 02:49

I can't for the life of me figure out where I'm going wrong here with Intro to Objects II 20/30

function Penguin(name) {
    this.name = name;
    this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
function Emperor(name) {
    this.name = name;
}

Emperor.prototype = new Penguin();
// create an "emperor" object and print the number of legs it has
var emperor = new Emperor("Mickey");
console.log(emperor.numLegs);

Any thoughts?

dc
@dcsan
Aug 03 2015 02:50
bf objects
CamperBot
@camperbot
Aug 03 2015 02:50
can't find a bonfire called objects
Rex Schrader
@SaintPeter
Aug 03 2015 02:53
@dcsan Man, there sure are a lot of verbs. find, explain, wiki, bf . . .
dc
@dcsan
Aug 03 2015 02:53
some are just aliased
wiki = help = explain
CamperBot
@camperbot
Aug 03 2015 02:53
no wiki entry for: help explain
:pencil: click here to create one now!after creating your page type update to reload it here
dc
@dcsan
Aug 03 2015 02:54
use depend on context
eg if you're explaining to someone else vs asking for help
but yeah
bf is for bonfires
CamperBot
@camperbot
Aug 03 2015 02:54
can't find a bonfire called is for bonfires
dc
@dcsan
Aug 03 2015 02:54
i may have to tone it down a bit in the main chats here
to not be so eager :)
@SaintPeter
btw do you have a blog or any notes of your bonfire solutions?
or know anyone who does?
CamperBot
@camperbot
Aug 03 2015 02:55
type bonfire name
to get some info on that bonfire here
Rex Schrader
@SaintPeter
Aug 03 2015 02:56
@dcsan I just have my profile page. I did tend to comment, where needed, but no detailed notes.
dc
@dcsan
Aug 03 2015 02:56
your comments went where? on GH issues?
SojournerOctocat
@SojournerOctocat
Aug 03 2015 02:56
I'm reading https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce. The first example has the index starting at 1. The second example has the index starting at 0. But the code is pretty much the same for both examples. Can someone explain what's the difference in the index starting values?
Rex Schrader
@SaintPeter
Aug 03 2015 02:58
@dcsan Inline comments . . . // This is a comment
dc
@dcsan
Aug 03 2015 02:58
oh right in your code. got it
i thought you might be playing code golf to keep it concise as possible!
Rex Schrader
@SaintPeter
Aug 03 2015 02:59
I never play code golf. I have had the misfortune of needing to maintain my own code. It's surprising how quickly you become a fan of comments when you go back to read something you wrote 5 years prior.
@SojournerOctocat I'm not sure which example you're pointing to.
Theresa Hoang
@Teehoang
Aug 03 2015 03:00
Hi all! Does anyone know why they are all checked off but it's not letting me more onto the next bonfire?
Screen Shot 2015-07-31 at 5.59.41 PM.png
Rex Schrader
@SaintPeter
Aug 03 2015 03:00
@Teehoang If you get "stuck" you can always go to the map and select the next Bonfire
CamperBot
@camperbot
Aug 03 2015 03:00
type bonfire name
to get some info on that bonfire here
Theresa Hoang
@Teehoang
Aug 03 2015 03:01
Screen Shot 2015-08-02 at 10.59.39 PM.png
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:01
@SaintPeter The first table directly following The callback would be invoked four times, with the arguments and return values in each call being as follows: and then the second table directly following If you were to provide an initial value as the second argument to reduce, the result would look like this:
Rex Schrader
@SaintPeter
Aug 03 2015 03:02
@Teehoang Oh . . you mean it's not passing. Make a copy of your code and refresh the page. Paste your code back in and hit Run Code, see if that helps.
Theresa Hoang
@Teehoang
Aug 03 2015 03:02
@SaintPeter yeah i was thinking about that but im worried i wont be able to work on the non-profit projects later if i dont have all the practices checked off
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:02
I don't see how they're setting the values for the index. It seems as if the initial index value of 1 is automatic, but then how is the initial value of index 0 in the second table?
Theresa Hoang
@Teehoang
Aug 03 2015 03:02
@SaintPeter i tried that a few times but it's not working
Rex Schrader
@SaintPeter
Aug 03 2015 03:04
@SojournerOctocat Ok, this was a bit rough for me to get too. There are two variables in the callback: previousValue, currentValue, right? If you just do reduce with only a callback, the first time through the loop previousValue will be equal to inputArray0, and currentValue will be equal to inputArray1. Does that make sense?
@Teehoang if you don't mind, paste your code for me and I'll give it a try. Do you know how to use the ``` marks to paste?
wiki code
CamperBot
@camperbot
Aug 03 2015 03:04
no wiki entry for: code
:pencil: click here to create one now!after creating your page type update to reload it here
Rex Schrader
@SaintPeter
Aug 03 2015 03:04
wiki paste
CamperBot
@camperbot
Aug 03 2015 03:04
no wiki entry for: paste
:pencil: click here to create one now!after creating your page type update to reload it here
Rex Schrader
@SaintPeter
Aug 03 2015 03:04
find paste
CamperBot
@camperbot
Aug 03 2015 03:04
find paste
nothing found
dc
@dcsan
Aug 03 2015 03:05
wiki forma
CamperBot
@camperbot
Aug 03 2015 03:05

:pencil: code formatting

Steps to format your code for pasting in the chat room.

Inline code

This an inline `<paste code here>` code formatting.

^single backtick at start and end around the inline code.

 

Code Block

``` ⇦ Type 3 backticks, 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

Theresa Hoang
@Teehoang
Aug 03 2015 03:05
i think so. ive seen it mentioned it the comments a few times. i'll give it a try.
Rex Schrader
@SaintPeter
Aug 03 2015 03:05
@dcsan You = The Man
dc
@dcsan
Aug 03 2015 03:05
@Teehoang
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:05
@SaintPeter First table, first call, the index value is 1. Second table, first call, the index value is 0. They didn't set the index, so I assume the index is automatic. But if it's automatic, why are the values different?
dc
@dcsan
Aug 03 2015 03:05
just have to know where to look.
Theresa Hoang
@Teehoang
Aug 03 2015 03:05
@dcsan thanks!
dc
@dcsan
Aug 03 2015 03:06
@abhisekp wrote that up
cheesestrings
@cheesestrings
Aug 03 2015 03:06
hey, does anyone have problems with .splice not working, or is it just me?
Rex Schrader
@SaintPeter
Aug 03 2015 03:07
@SojournerOctocat ok, so if you call reduce with an initial value, then "previousValue" === initial value, "currentValue" = arrayInput[0]. Look at the two calls:
arr.reduce(function(prev, curr) { /* ... code here */ });  // No initial value
arr.reduce(function(prev, curr) { /* ... code here */ }, 0 );  // Initial value passed (0)
@SojournerOctocat The difference is the presence of an initial value in the function call
@cheesestrings Might be just you :D - share some code and I'll take a look?
Theresa Hoang
@Teehoang
Aug 03 2015 03:08
 var arr = [
   [4, 5, 1, 3],
   [13, 27, 18, 26],
   [32, 35, 37, 39],
   [1000, 1001, 857, 1]
];

function largestOfFour (arr) {

    var maxArray = [];

    for (var i = 0; i < arr[0].length; i++) {
        var possibleValues = [];

        for (var j = 0; j < arr.length; j++) {
            possibleValues.push(arr[j][i]);
        }

        var highest = Math.max.apply(null, possibleValues);

        maxArray.push(highest);
    }
    return maxArray;
}

console.log(largestOfFour(arr)); 


largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
@SaintPeter
Lightwaves
@Lightwaves
Aug 03 2015 03:08
Wait who made the bot?
It's awesome
cheesestrings
@cheesestrings
Aug 03 2015 03:09
@saintpeter any time i try to use it, it gives me the error str.splice is not a function.
Rex Schrader
@SaintPeter
Aug 03 2015 03:09
@Lightwaves, @dcsan made the bot :D
cheesestrings
@cheesestrings
Aug 03 2015 03:09
its new as of yesterday.
Lightwaves
@Lightwaves
Aug 03 2015 03:09
@dcsan definitely the man
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:10
@SaintPeter That's not what I was referring to.
Rex Schrader
@SaintPeter
Aug 03 2015 03:10
@cheesestrings That's because it's not. splice is an ARRAY function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
not a string function. if str really is a string then splice will not work on it.
@SojournerOctocat Then you've lost me. I'm telling you that the starting index will be different, depending on if you pass in an initial value or not.
cheesestrings
@cheesestrings
Aug 03 2015 03:12
ah, whoops, my bad.
thanks!
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:13
@SaintPeter So you're saying that in that first and second table, they set the initial value for the indexes?
Rex Schrader
@SaintPeter
Aug 03 2015 03:13
@Teehoang ok, you have to remove that console.log statement near the end. That is causing all kinds of problems.
@SojournerOctocat In the first table they did not pass in an initial value in their call to reduce. In the second table they did. You see where the second parameter to reduce is an initial value?
@Teehoang In part, because arr is not defined outside of the function. You had defined it, which was probably not a good idea. Remove the console.log(arr) and then you'll see that your code is not passing all the tests.
Theresa Hoang
@Teehoang
Aug 03 2015 03:17
@SaintPeter hmm i just refreshed, re-pasted the code and ran it and it worked again?
Rex Schrader
@SaintPeter
Aug 03 2015 03:17
@Teehoang Did you remove that console.log statement? When I remove the var arr definition up top it only passed 1 of the tests.
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:18
@SaintPeter I'm asking about the intial value of the index, not the initial value in the call to reduce.
Theresa Hoang
@Teehoang
Aug 03 2015 03:18
@SaintPeter yep i refreshed removed it and tried the code again and it passed
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:19
@SaintPeter The indexes are in the 4th column of the table.
Rex Schrader
@SaintPeter
Aug 03 2015 03:20
@SojournerOctocat Yes. What I am telling you is that the presence of an initial value CHANGES the first index. If there is no initial value, then the first index is 0 (for "previousValue") and if there IS an initial value then the first index is 1.
Theresa Hoang
@Teehoang
Aug 03 2015 03:20
@SaintPeter ahhh ok i removed the var arr at the top too and now it only passes one. do you have any tips on what im doing wrong?
Rex Schrader
@SaintPeter
Aug 03 2015 03:20
@Teehoang Let me take a deeper look at the code. Give me a moment.
Theresa Hoang
@Teehoang
Aug 03 2015 03:20
@SaintPeter ok thank you!
SojournerOctocat
@SojournerOctocat
Aug 03 2015 03:22
@SaintPeter But the first table has no initial value and the index in the first call row is 1. The second table, which does pass an initial vaue, has 0 for the index in the first call row.
Rex Schrader
@SaintPeter
Aug 03 2015 03:23
@SojournerOctocat oops, then maybe I got it backward? The main point is that the presence or absence of an initial value is the difference.
@Teehoang ok, I found the problem. Do you want me to tell you, or do you want me to show you how I debugged it?
Theresa Hoang
@Teehoang
Aug 03 2015 03:25
@SaintPeter please show me how you debugged it
Rex Schrader
@SaintPeter
Aug 03 2015 03:25
@Teehoang Look here: http://repl.it/zt9 - I took your code and added a console.log to line 14. That way I could see what the value of "highest" was for each loop. Take a look at that output and see if you can figure out what is wrong.
Theresa Hoang
@Teehoang
Aug 03 2015 03:26
@SaintPeter ok trying now!
Angel Jimenez
@aJimmer
Aug 03 2015 03:26
Hello everyone! Any OS X users in here?
Alex Labanino
@labanino
Aug 03 2015 03:26
@Crashman1012 [^a-zA-Z] gets all letters, lower and uppercase and convert them .toLowerCase();
Theresa Hoang
@Teehoang
Aug 03 2015 03:28
@SaintPeter is this it? SyntaxError: missing ) after argument list
Rex Schrader
@SaintPeter
Aug 03 2015 03:29
@Teehoang Humm, nope, when I run the code I didn't get that error. You have a small logic error. Were you able to click through to my repl.it example?
Theresa Hoang
@Teehoang
Aug 03 2015 03:31
@SaintPeter should i be looking at the left or right side of the screen?
Rex Schrader
@SaintPeter
Aug 03 2015 03:32

@Teehoang When you click the "Run" button you'll see the console output on the right hand side of the screen. You should see a list of numbers there:

1000
1001
857
39
=> [ 1000, 1001, 857, 39 ]

Those are the values of "highest" at that point in the loop.

Feners4
@Feners4
Aug 03 2015 03:32
how could I get a user name per line and without repeating in?:
http://codepen.io/Feners4/pen/EjONEe
Rex Schrader
@SaintPeter
Aug 03 2015 03:32
@Teehoang The thing that caught my eye is that the first array only has low numbers in it. There is no way it's "highest" value could be 1000, right?
Brock
@br0ck
Aug 03 2015 03:32
@solerxnaut Sure
Rex Schrader
@SaintPeter
Aug 03 2015 03:33
@Teehoang So the quesiton is: How the heck did that "high" number get in there?
Theresa Hoang
@Teehoang
Aug 03 2015 03:36
@SaintPeter is it because var maxArray is only looking at the largest array?
Rex Schrader
@SaintPeter
Aug 03 2015 03:36
@Teehoang But how would that be possible? You're starting from 0 for both i and j, right?
Theresa Hoang
@Teehoang
Aug 03 2015 03:37
@SaintPeter should i change the var j = value in the for loop?
Rex Schrader
@SaintPeter
Aug 03 2015 03:39
@Teehoang Here, I've added another debug line: http://repl.it/zt9/2 Take a look at possibleValues - does it have the correct contents?
@Feners4 took at look at your code - I think your ng-repeat is at the wrong level - it should be associated with the ul in the line above.
Marc Davenport
@oneate7
Aug 03 2015 03:42
Anyone have any tips for dealing with currency in JS?
I understand that there's an issue with floats, but I can't figure out how to get around it.
Rex Schrader
@SaintPeter
Aug 03 2015 03:44
@Feners4 this works:
main(ng-app='heyTwitch')
  section(ng-controller='MainCtrl')
    header
      ul#mainMenu
        li

    ul#people(ng-repeat='user in getUsers')
      li
        a(href='http://twitch.tv/{{user}}' target='_blank') {{user}}
Feners4
@Feners4
Aug 03 2015 03:45
@SaintPeter Yup, thanks, now I believe I have to edit my array because its still displays all usernames per line..
Rex Schrader
@SaintPeter
Aug 03 2015 03:46
@Feners4 Maybe? If you look at the code I did above it actually displayed properly
blob
Feners4
@Feners4
Aug 03 2015 03:47
@SaintPeter really? ok let me revise
Rex Schrader
@SaintPeter
Aug 03 2015 03:47
@Feners4 Note that I put the a inside the li
Feners4
@Feners4
Aug 03 2015 03:49
@SaintPeter Ah! Thank you very much sir!
Rex Schrader
@SaintPeter
Aug 03 2015 03:49
@Feners4 Glad to be of service :D I had more time to look at it this time around.
Feners4
@Feners4
Aug 03 2015 03:54
@SaintPeter so, in order to add the display pic, should I list it directly under a(href='http://twitch.tv/{{user}}' target='_blank') {{user}}
Rex Schrader
@SaintPeter
Aug 03 2015 03:55
@Feners4 If you intend that it be right justified, then yes. Of course you can adjust your CSS to suit. Or you could put it before the anchor tag
@Feners4 The main thing is that it does need to be nested under the li tag
Feners4
@Feners4
Aug 03 2015 03:56
@SaintPeter Ok!
Russell Westberry
@russbus
Aug 03 2015 03:59
Just started in on the bonfires. Did what I thought was right for factorialize a number, but in Googling after the fact, I found a bunch of arguments RE: recursion vs. iteration. I used recursion because it always seems to look nicer, but parts of the internet says it's less efficient. Any input?
William Wagner
@wcwagner
Aug 03 2015 03:59
Hi I'm on the palindrome bonfire, and I got all the requirements to pass yet it wont come up with the 'on to the next challenge' after i hit run code... What should i do?
Rex Schrader
@SaintPeter
Aug 03 2015 04:00
@russbus Yeah, recursion is less efficient. Personally, I avoid it if I can, because there are so many ways it can go wrong. That said, there are some things that are just more "elegantly" solved with it.
@Stfyou Can you share your code? I'll give it a try.
wiki forma
CamperBot
@camperbot
Aug 03 2015 04:01

:pencil: code formatting

Steps to format your code for pasting in the chat room.

Inline code

This an inline `<paste code here>` code formatting.

^single backtick at start and end around the inline code.

 

Code Block

``` ⇦ Type 3 backticks, 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

Theresa Hoang
@Teehoang
Aug 03 2015 04:03
@SaintPeter the possible values look correct? just not in the same order
William Wagner
@wcwagner
Aug 03 2015 04:03
@SaintPeter
Rex Schrader
@SaintPeter
Aug 03 2015 04:04
@Teehoang Nope, the possible values contain values from a later array
William Wagner
@wcwagner
Aug 03 2015 04:04
function palindrome(str) {
  // Good luck!
  var regex = /[^A-Za-z0-9]+/;
  plain_str = str.replace(regex, "");
  arr = plain_str.split("");
  arr.reverse();
  newStr = arr.join("");
  if (plain_str === newStr) {
    return true;
  }
  return false;
}
console.log(palindrome("race car"));
Rex Schrader
@SaintPeter
Aug 03 2015 04:05

@Teehoang The problem is here:

for (var j = 0; j < arr.length; j++) {
            possibleValues.push(arr[j][i]);
        }

You have the wrong order of j and i. The indexes go from outside to inside.

@Stfyou Interesting - I'm getting the same issue. Let me poke at it and see if I can figure out why.
William Wagner
@wcwagner
Aug 03 2015 04:06
@SaintPeter Thanks a lot for the help, I will do the same
Rex Schrader
@SaintPeter
Aug 03 2015 04:09
@Stfyou Interesting. Your code is definitely not right. I'm trying to figure out why it's showing as correct.
Theresa Hoang
@Teehoang
Aug 03 2015 04:10
OHHHH i see now @SaintPeter thank you so much for taking the time to explain!
Rex Schrader
@SaintPeter
Aug 03 2015 04:10
@Teehoang Glad to help :D
dc
@dcsan
Aug 03 2015 04:12
thanks @SaintPeter
CamperBot
@camperbot
Aug 03 2015 04:12
dcsan sends karma to saintpeter :thumbsup: :sparkles: :sparkles:
Robert
@rc242
Aug 03 2015 04:13
heyo.
Rex Schrader
@SaintPeter
Aug 03 2015 04:13
@dcsan new pattern: @username thank you
William Wagner
@wcwagner
Aug 03 2015 04:15
@SaintPeter my reg expression isn't working properly, I think that's the problem & I didn't use toLowerCase(). I wonder why all the tests came back as correct though
Rex Schrader
@SaintPeter
Aug 03 2015 04:15
@Stfyou Yeah, that's a real puzzle. That's the second time I've seen this behavior and I'm trying to track down the cause.
@Stfyou There is something funky in hipster town and I'm gonna find it!
William Wagner
@wcwagner
Aug 03 2015 04:16
@SaintPeter Groovy.
Rex Schrader
@SaintPeter
Aug 03 2015 04:17
@Stfyou ok, got some of it: lines 5 and 6, you need variables to be defined.
@Stfyou I mean you need to put a var in front of those lines
Not doing so causes all of the tests to pass (improperly)
William Wagner
@wcwagner
Aug 03 2015 04:18
@SaintPeter Okay thanks, I just switched from learning ruby so its hard to get that syntax out of my head.
Rex Schrader
@SaintPeter
Aug 03 2015 04:18
@Stfyou Haha - no worries. I have that problem all the time when I switch languages.
@Stfyou This line does nothing:
arr.reverse();
William Wagner
@wcwagner
Aug 03 2015 04:20
@SaintPeter So i would have to put var newarr = arr.reverse();?
Rex Schrader
@SaintPeter
Aug 03 2015 04:21
@Stfyou The problem with your regex is that it needs to be "global".
Yes, you could do newarr, or just arr = arr.reverse();
Rex Schrader
@SaintPeter
Aug 03 2015 04:30
I'm off, night all
dc
@dcsan
Aug 03 2015 04:31
thanks @SaintPeter
CamperBot
@camperbot
Aug 03 2015 04:32
dcsan sends karma to saintpeter :thumbsup: :sparkles: :sparkles:
Luis Felipe López G.
@luishendrix92
Aug 03 2015 04:33
I need help with the bonfire "Sorted union" for what I read, it should return [3, 5, 4, 2, 1] right? Why is it asking me to return [ 1, 3, 2, 5, 4 ]
CamperBot
@camperbot
Aug 03 2015 04:33
type bonfire name
to get some info on that bonfire here
dc
@dcsan
Aug 03 2015 04:36
bonfire sorted
CamperBot
@camperbot
Aug 03 2015 04:36

:fire:Bonfire: Sorted Union :link:

function unite(arr1, arr2, arr3) {
  return arr1;
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);

Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.

for more info: bf details bf links bf script bf wiki bf spoiler

Matthew Vogel
@matthewsvm
Aug 03 2015 04:36
good night @SaintPeter :)
Luis Felipe López G.
@luishendrix92
Aug 03 2015 04:38
Values that don't interesect are 3, 5 and 4, and the values that are present in the three arrays are 1 and 2, but I still don't understand what should the function return, I'm stuck .
Matt Everson
@matteverson
Aug 03 2015 04:40
bf details
CamperBot
@camperbot
Aug 03 2015 04:40

:fire:Bonfire: Sorted Union :link:

function unite(arr1, arr2, arr3) {
  return arr1;
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);

Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.
In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.
The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.
Check the assertion tests for examples.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Arguments object,
Array.reduce())


  • bonfire info for more info
  • bonfire links
  • bonfire script for the script
  • bonfire spoiler for some clues on how to solve it
  • bonfire wiki for related info from the wiki
Guillermo Hernandez Jr
@guillermohernandez
Aug 03 2015 04:40
killing it @SaintPeter
Matt Everson
@matteverson
Aug 03 2015 04:41
@luishendrix92 You're looking for all of the distinct values in all of the arrays, so you'd return an array containing those values.
Luis Felipe López G.
@luishendrix92
Aug 03 2015 04:42
@matteverson Distinct values are [3, 5, 4], those are the unique values in the 3 arrays. The assert tests fail though.
Matt Everson
@matteverson
Aug 03 2015 04:44
The test says what it expects a given input to return. What does that assert say?
Luis Felipe López G.
@luishendrix92
Aug 03 2015 04:44
assert.deepEqual(unite([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'should return the union of the given arrays');should return the union of the given arrays: expected [ 3, 5, 4 ] to deeply equal [ 1, 3, 2, 5, 4 ]
assert.deepEqual(unite([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'should not flatten nested arrays');should not flatten nested arrays: expected [ 3, 5, 4 ] to deeply equal [ 1, 3, 2, [ 5 ], [ 4 ] ]
Matt Everson
@matteverson
Aug 03 2015 04:45
Looks like it expects that input to include 1 and 2 as well, meaning it's not looking for values that aren't repeated, just a list of unique values.
s/input/output
There's another bonfire that does what you're thinking of, called symmetric difference.
Abdul R. Taleb-Agha
@atalebagha
Aug 03 2015 04:47
Hi all, I’m having a bit of trouble on Bonfire: Sum all odd fibonacci numbers. Any help will be appreciated
function sumFibs(num) {
  var total = 1;
  var array = [0,1];
  var state = true;
  var x = 2;

  while(state === true) {
    array.push(array[x-1] + array[x-2]);
    if(array[x] % 2 !== 0) {
      total += array[x];
    }
    x++;
    if(array[x] === num) { state = false; break;}
  }
 return total;
}
it’s getting stuck and running an infinite loop and bombs my browser. I guess there is something I’m not noticing...
Matt Everson
@matteverson
Aug 03 2015 04:51
@atalebagha The value at array[x] is a fib number. 1,1,2,3,5,8,13 <- what if my num was 10?
Luis Felipe López G.
@luishendrix92
Aug 03 2015 04:51
I think I get it now, wow, how dumb of me not to remember A U B which doesn't repeat values.
And it expects 1, 3, 2, 5, 4 because 1, 3, 2 were like that in the first array and then came 5 and 4
Matt Everson
@matteverson
Aug 03 2015 04:52
@luishendrix92 Spot on :)
SojournerOctocat
@SojournerOctocat
Aug 03 2015 04:55
Working on Bonfire Sorted Union. Code below. My reduce method is processing a flat array and returning a non-flat array. Why?
function unite(arr1, arr2, arr3) {
    var arrUnion = [];
    var arrFlat = Array.prototype.slice.call(arguments).reduce(function(previous, current, index, array) {
        if (arrUnion.indexOf(previous) == -1) {
            return arrUnion.push(previous);
        }
    });

    return arrUnion; // [[1, 2, 3], 1]
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);
Elliescode
@EllieAdam
Aug 03 2015 04:57
hello!
Feners4
@Feners4
Aug 03 2015 04:57
help with iterating and extracting value from : http://codepen.io/Feners4/pen/EjONEe
CamperBot
@camperbot
Aug 03 2015 04:57
no wiki entry for: with iterating and extracting value from httpcodepeniofeners4penejonee
:pencil: click here to create one now!after creating your page type update to reload it here
Matt Everson
@matteverson
Aug 03 2015 04:57
@SojournerOctocat It's not processing a flat array - each element it receives in current will be one of the subarrays in arguments
SojournerOctocat
@SojournerOctocat
Aug 03 2015 04:58
I flattened the arguments before sending it for processsing @matteverson
@matteverson Oh. No I didn't.
Elliescode
@EllieAdam
Aug 03 2015 04:59
This message was deleted
This message was deleted
Matt Everson
@matteverson
Aug 03 2015 05:00
@EllieAdam You can paste text here between two lines containing triple backticks --> ``` and it will be turned into code
@EllieAdam But I can guess an answer: Instead of multiple class attributes, do this -> class="red-text blue-text" <- separate multiple classes by a space. Last class takes precedence over previous ones.
Elliescode
@EllieAdam
Aug 03 2015 05:05
thanks!
Darrell Wong
@darrell1226
Aug 03 2015 05:40

Am I doing something wrong here?

var app = angular.module("myApp", []);
  app.controller('MainController', ['$scope', '$http', function($scope, $http) { 
    $http.get('http://www.freecodecamp.com/stories/hotStories')
      .success(function(response){
      $scope.articles = response.news;
      $scope.discuss = 'http://www.freecodecamp.com/news/' + response.storyLink.replace(/\s/g,'-');
    });   
  }]);
<div class="main" ng-controller="MainController">
      <div class="row">
        <div class="col-xs-3 1" ng-repeat="article in articles">
          <a href="{{article.link}}"><img src= {{article.image}}/><h4>{{article.headline}}</h4></a>
          <button><a href={{discuss}}>Discuss</a></button>
        </div>
      </div>
    </div>

It's displaying {{article.headline}} instead of the article's headline. Seems like Angular isn't even reading the {{}}

ronald
@ronstarcool
Aug 03 2015 06:34
{{> ?
idk much about this though..
does that work?
@darrell1226 ?
barbiekini
@barbiekini
Aug 03 2015 06:43

Using Bootstraps col-xs element to style a form so the radio button elements fit evenly across the page. See code below, can anyone tell me what I have done wrong please?

<p>Things cats love:</p>

<div class='row'>
<ul>
<div class='col-xs-6'>
<li>cat nip</li>
</div>
<div class='col-xs-6'>
<li>laser pointers</li>
</div>
<div class='col-xs-6'>
<li>lasagna</li>
</div>
</ul>
</div>

Russell Westberry
@russbus
Aug 03 2015 06:46
@barbiekini Looks like you're styling a list and not the radio buttons.
barbiekini
@barbiekini
Aug 03 2015 06:53
and that would be it! thanks so much Russbus. Knew it had to be something simple :)
Russell Westberry
@russbus
Aug 03 2015 06:57
@barbiekini No problem. That seems to be a thing that pops up a lot in the chat.
Amrinder Singh
@singhamrinder
Aug 03 2015 07:07
@darrell1226 Seems like your angular is not bootstraping
Javed
@JayBee007
Aug 03 2015 07:37
What am I doing wrong?
function diff(arr1, arr2) {
    // Find the largest array length
    var largeArray = findLargestArray(arr1,arr2);

    var fil = arr2.filter(arrayFilter);

    function arrayFilter(value){
        for(var i = 0; i < largeArray.length; i++){
        return value === arr1[i];
    }
}

    return fil;
}
function findLargestArray(arr1,arr2){
    if(arr1.length > arr2.length){
        return arr1;
    }else{
        return arr2;
    }
}



diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Ammar Ali Shah
@AmmarAliShah
Aug 03 2015 07:49
I need a little git help
I want to revert permanently back to a previous commit
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 07:55
git reset --hard (commit-code)
Ammar Ali Shah
@AmmarAliShah
Aug 03 2015 08:03
@vincepandolfo thank you
KieronDowie
@KieronDowie
Aug 03 2015 08:18
This isn't from a waypoint challenge, but what does this code do?
var o = this.conf, l, i, s, r, j;
I've never seen var used like that before.

Or is it just the same as saying

var o = this.conf;
var l;
var i;

etc.?

John Chau
@ydjjabt
Aug 03 2015 08:45
@JayBee007 u didnt use filter array method correctly...way off the hook!
@KieronDowie this is for object such as array, object and function object
that code is completely wrong
Joris Labie
@labiej
Aug 03 2015 08:48
@ydjjabt that code is valid
it's the same as defining var a1, a2, a3, ..., an; except they assign a value during declaration
@KieronDowie You are correct with regards to the second snippet
I would only group empty variables in that way. Much clearer
kineticdreams
@kineticdreams
Aug 03 2015 09:14
Hello!
Can anyone help me with Bonfire: Symmetric Difference?
function sym(args) {
    args = Array.prototype.slice.call(arguments);
    var flat = args.reduce(function(a, b){
        return a.concat(b).sort();});
    for(var i = 1, len = flat.length; i < len; i++){
        console.log(i, len, flat[i - 1],  flat[i], flat);
        if(flat[i - 1] === flat[i]){
            flat.splice(i - 1, 2);
            len -= 2;
            console.log(i, len, flat[i - 1],  flat[i], flat);
        }
    }
    return flat;
}

sym([1, 2, 3], [5, 2, 1, 4]);
CamperBot
@camperbot
Aug 03 2015 09:16
type bonfire name
to get some info on that bonfire here
kineticdreams
@kineticdreams
Aug 03 2015 09:17
bonfire Symmetric Difference
CamperBot
@camperbot
Aug 03 2015 09:17
can't find a bonfire called symmetric difference
Cristian V. Nica
@cristianvnica
Aug 03 2015 09:18
This message was deleted
@camperbot nice hat!
Joris Labie
@labiej
Aug 03 2015 09:22
bonfire Symmetric_Difference
CamperBot
@camperbot
Aug 03 2015 09:22
can't find a bonfire called symmetric_difference
Joris Labie
@labiej
Aug 03 2015 09:22
bonfire "Symmetric Difference"
CamperBot
@camperbot
Aug 03 2015 09:22
can't find a bonfire called symmetric difference
Paolo Alejandro Anchoriz
@paoloanchoriz
Aug 03 2015 09:22
Got trolled by the camper bot
Joris Labie
@labiej
Aug 03 2015 09:23
guess it's not ready yet
bonfire Symmetric
CamperBot
@camperbot
Aug 03 2015 09:23
can't find a bonfire called symmetric
Joris Labie
@labiej
Aug 03 2015 09:27
I know, was testing camperbot
kineticdreams
@kineticdreams
Aug 03 2015 09:28
have you completed it?
David Suilea
@Foryah
Aug 03 2015 09:28
bonfire symmetric-difference
CamperBot
@camperbot
Aug 03 2015 09:28
can't find a bonfire called symmetric-difference
David Suilea
@Foryah
Aug 03 2015 09:29
Bonfire: "Symmetric Difference"
CamperBot
@camperbot
Aug 03 2015 09:29
can't find a bonfire called symmetric difference
David Suilea
@Foryah
Aug 03 2015 09:30
Bonfire: Reverse a String
CamperBot
@camperbot
Aug 03 2015 09:30

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.

for more info: bf details bf links bf script bf wiki bf spoiler

David Suilea
@Foryah
Aug 03 2015 09:30
Hehe... it works for other bonfires :)
CamperBot
@camperbot
Aug 03 2015 09:30
type bonfire name
to get some info on that bonfire here
denisnurboja
@denisnurboja
Aug 03 2015 09:33
bonfire reverse a string
CamperBot
@camperbot
Aug 03 2015 09:33

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.

for more info: bf details bf links bf script bf wiki bf spoiler

denisnurboja
@denisnurboja
Aug 03 2015 09:33
bf details
CamperBot
@camperbot
Aug 03 2015 09:33

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.
You may need to turn the string into an array before you can reverse it.
Your result must be a string.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Global String Object,
String.split()),
Array.reverse()),
Array.join())


  • bonfire info for more info
  • bonfire links
  • bonfire script for the script
  • bonfire spoiler for some clues on how to solve it
  • bonfire wiki for related info from the wiki
denisnurboja
@denisnurboja
Aug 03 2015 09:34
bonfire spoiler
CamperBot
@camperbot
Aug 03 2015 09:34
[0] Reverse the provided string.
denisnurboja
@denisnurboja
Aug 03 2015 09:34
bonfire script
CamperBot
@camperbot
Aug 03 2015 09:34
function reverseString(str) {
  return str;
}

reverseString('hello');
Joris Labie
@labiej
Aug 03 2015 09:35
@kineticdreams I did solve that symmetric difference, you having problems?
kineticdreams
@kineticdreams
Aug 03 2015 09:40
@labiej yes I do
If you will scroll up you can see what I came up with so far
Joris Labie
@labiej
Aug 03 2015 09:44
you shouldn't increment i whenever you remove 2 elements
Another problem is the order
kineticdreams
@kineticdreams
Aug 03 2015 09:48
I tried with while loop and I can't figure it out @labiej
Joris Labie
@labiej
Aug 03 2015 09:49
you understand what I meant with the first remark?
kineticdreams
@kineticdreams
Aug 03 2015 09:52
yes @labiej
I solve it with:
function sym(args) {
    args = Array.prototype.slice.call(arguments);
    var flat = args.reduce(function(a, b){
        return a.concat(b).sort();});
    for(var i = 1, len = flat.length; i < len;){
        if(flat[i - 1] === flat[i]){
            flat.splice(i - 1, 2);
            len -= 2;
        } else {
            i++;
        }
    }
    return flat;
}

sym([1, 2, 3], [5, 2, 1, 4]);
but now I realize Tht I'm not suppose to sort the result...
Ramses
@ram535
Aug 03 2015 09:53
hello
Joris Labie
@labiej
Aug 03 2015 09:53
indeed, another issue is that you should remove duplicate values from the same argument
Ramses
@ram535
Aug 03 2015 09:54
I have a problem with "Waypoint: Add Images to your Website"
How do I paste code in this chat?
Akram
@niwox
Aug 03 2015 09:59
Anyone comfortable with gulp here?
Joris Labie
@labiej
Aug 03 2015 10:00
@ram535 start with 3 backticks ```
Ramses
@ram535
Aug 03 2015 10:00
ty
ty @labiej
Joris Labie
@labiej
Aug 03 2015 10:01
if it's on the first line and you enter there should be added another 3. Between those you enter the code
Ramses
@ram535
Aug 03 2015 10:02
<img src="http://i1108.photobucket.com/albums/h412/BrownDog341/32330_cat-cats-cute-kitten-photography-favimcom-142513.jpg"/>
I added this image in the challenge but I don't know why it doesn't let go to the next challenge
Joris Labie
@labiej
Aug 03 2015 10:04
use the bit.ly url
the interpreter doesn't know the long url
KieronDowie
@KieronDowie
Aug 03 2015 10:04
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:06
@ram535 if you are on the challenge you need the specific image they tell you to input... @KieronDowie sent the right one (probablly)
Ramses
@ram535
Aug 03 2015 10:06
ty @labiej @KieronDowie . Now it works
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:07
bonfire Title Case a Sentence
CamperBot
@camperbot
Aug 03 2015 10:07

:fire:Bonfire: Title Case a Sentence :link:

function titleCase(str) {
  return str;
}

titleCase("I'm a little tea pot");

Return the provided string with the first letter of each word capitalized.

for more info: bf details bf links bf script bf wiki bf spoiler

Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:07
anyone did this yet? i would enjoy discussion of the method used
Joris Labie
@labiej
Aug 03 2015 10:09
I did it
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:09
@labiej going to private message you
Irfan Kucuk
@Ikucuk
Aug 03 2015 10:10
@camperbot doesn't reply to private messages?
KieronDowie
@KieronDowie
Aug 03 2015 10:13
@Jorgixhallo I did it like this, I remember someone using an easier method to set the first character to uppercase though, can't remember how it was done.
function titleCase(str) {
  str=str.toLowerCase();
  var words=str.split(" ");
  for (var i=0;i<words.length;i++)
    {
     var letters=words[i].split("");  
     letters[0]=letters[0].toUpperCase();
      words[i]=letters.join("");
    }
  str=words.join(" ");
  return str;
}
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:16
mine is a bit different... But i gess as long as it does the work it's ok xD
function titleCase(str) {
  var split = str.split(' ');
  var toUpper = '';

  for(var i=0; i<split.length; i++){
    for (var j=0; j<split[i].length; j++){
      if(j===0){
        toUpper += split[i].charAt(j).toUpperCase();
      }else{
        toUpper += split[i].charAt(j).toLowerCase();
      }
    }
    if(i!=split.length-1){
      toUpper += ' ';
    }
  }
  return toUpper;
}

titleCase("I'm a little tea pot");
could change that i!= with an else if statement. other than that i think it's ok
KieronDowie
@KieronDowie
Aug 03 2015 10:19
Ah, I considered doing it that way too at first.. Is js okay with naming variables the same name as functions?
var split = str.split(' '); Re: that
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:20
it is. the word split itself is not a "special" word so you can name your variables with that
Joris Labie
@labiej
Aug 03 2015 10:21
function titleCase(str) {

  return str.split(' ').
            map( function(elem){
                return elem.toLowerCase().charAt(0).toUpperCase() + elem.toLowerCase().substr(1);
            }).join(' ');

}
I believe this is close to minimal code
Sean Campbell
@natac13
Aug 03 2015 10:22
Hey everyone I am on spianl tap banfire and I have all the test green and passing but it wont advance I am just curious if this is a bug or my code is somehow wrong.
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  arr = str.split('');
  var re = new RegExp(/[A-Z]/);

  console.log(str.search(re));
  if(str.search(/\s/g) === -1) {
    while(str.search(re) !== -1) {
      var index = str.search(re);
      console.log(str);
      str = str.slice(0, index) + ' ' + str.charAt(index).toLowerCase() + str.slice(index+1);
      arr.splice(index, 0, ' ');
      console.log(arr);
      }
  }

  console.log(arr);

  str = arr.join('');
  str = str.toLowerCase();
  str = str.replace(/[\s|_]/g, '-');
  return str;
}

spinalCase('This Is Spinal Tap');
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:24
This message was deleted
CamperBot
@camperbot
Aug 03 2015 10:24
can't find a bonfire called spinalcase
Sean Campbell
@natac13
Aug 03 2015 10:25
bonfire spinalTapCase
CamperBot
@camperbot
Aug 03 2015 10:25
can't find a bonfire called spinaltapcase
Sean Campbell
@natac13
Aug 03 2015 10:25
bonfire Spinal Tap Case
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:25
bonfire Spinal Tap Case
CamperBot
@camperbot
Aug 03 2015 10:25

:fire:Bonfire: Spinal Tap Case :link:

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  return str;
}

spinalCase('This Is Spinal Tap');

Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.

for more info: bf details bf links bf script bf wiki bf spoiler

:fire:Bonfire: Spinal Tap Case :link:

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  return str;
}

spinalCase('This Is Spinal Tap');

Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.

for more info: bf details bf links bf script bf wiki bf spoiler

Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:25
lol
Sean Campbell
@natac13
Aug 03 2015 10:25
lol I believe the code is working fine but yeah lol
Nepherius
@Nepherius
Aug 03 2015 10:26
bf spoiler
CamperBot
@camperbot
Aug 03 2015 10:26
[0] Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:27
@natac13 that re var should be named differentlly. It's a bit abstract. name it reg ou regex. Much easier for other people that read you code to understand...
Why are you console logging? To debug?
Nepherius
@Nepherius
Aug 03 2015 10:27
@natac13 wow natac you really over complicated that task :)
Sean Campbell
@natac13
Aug 03 2015 10:28
@Jorgixhallo yeah to just debug
Nepherius
@Nepherius
Aug 03 2015 10:28
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  return str.replace(/\s|_|([a-z](?=[A-Z]))/gm, '$1-').toLowerCase();
}

spinalCase('This Is Spinal Tap');
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:29
yeah. I would sugest @Nepherius implementation. Just replace spaces between words with - with a simple (maybe not that simple) regex
Sean Campbell
@natac13
Aug 03 2015 10:30
lol right
Nepherius
@Nepherius
Aug 03 2015 10:30
yeah not that simple, took me more than an hour to rigth the damn thing :)
Sean Campbell
@natac13
Aug 03 2015 10:31
yep and the last part of your pattern I don't understand yet... so yeah
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:33
just think for a moment. where can you have spaces?
  • first space (i gess you don't want to change it right?)
  • between words
  • at the end
    Just think of that and start building it from there. Regex can be very complicated at first.
Nepherius
@Nepherius
Aug 03 2015 10:33
(?=) thing saves the letter into $1
Jorge Almeida
@Jorgixhallo
Aug 03 2015 10:34
This message was deleted
Sean Campbell
@natac13
Aug 03 2015 10:36
@Nepherius so the last or in the pattern is looking for the last small letter in the previous word.... like prior to where the space should go?
Where the (?= is just to make sure a capital letter follows
Nepherius
@Nepherius
Aug 03 2015 10:40
think it's small letter followed but upper case
I suck at regex, did I mention that 1 line took me over an hour to write ?:))
Sean Campbell
@natac13
Aug 03 2015 10:42
Man it turned out really nice and you were able to help me learn something new!! so thank you!
I didnt know about the positive lookahead part
Nepherius
@Nepherius
Aug 03 2015 10:43
I'm glad
your code was so .. complicated :)
Sean Campbell
@natac13
Aug 03 2015 10:44
well I started with just the replace for spaces and underscore but didn't think of how to do the captial letter part with regex... so thats when all that other while loop bs came in
Nepherius
@Nepherius
Aug 03 2015 10:45
yeah that one took a lot of reading on stackoverflow
searching*
Matthew Barber
@Honno
Aug 03 2015 11:16
$(document).ready(function() { var $p = $('<p>Text</p>'); $('div#one').after($p); $('div#two').after($p); });
why does that put "Text" only after the second div?
And not bother
*both
oooh, so whilst <p>Text</p> physically displays after div#one, it's still treated as an object and is moved around again, don't mind me
I think? a bit confusing to get my head around heh
Jorge Almeida
@Jorgixhallo
Aug 03 2015 11:19
@Honno i gess that's it :)
Matthew Barber
@Honno
Aug 03 2015 11:20
I prefer the FCC in-house tutorials which gives you the efficient way of implementing the code for the previous solution to check up on when doing the next task xD
because now I'm not sure if my code was the way they were asking/can't proof check if the site messed up in accepting my solution
Jorge Almeida
@Jorgixhallo
Aug 03 2015 11:22
@Honno You are doing it on codecademy right?
Matthew Barber
@Honno
Aug 03 2015 11:22
yeah
@Jorgixhallo, I should use the callouts things in slack heh
gitter, even
Jorge Almeida
@Jorgixhallo
Aug 03 2015 11:26
@Honno Codecademy has some great tutorials and doesn't usually mess with solutions, so if you pass, you probablly got it right at the first place. They rework the code when it's needed
Matthew Barber
@Honno
Aug 03 2015 11:31
@Jorgixhallo very cool :)
Jorge Almeida
@Jorgixhallo
Aug 03 2015 11:38
@Honno If you're new to HTML&CSS I adivise you to make their tutorials because FCC ones are very incomplete
Elias Jørgensen
@EliasJorgensen
Aug 03 2015 12:12
function end(str, target) {
  if(str.substring(-target.length, target.length) === target) {
    return true;
  }else{
    return false;
  }
}

end('He has to give me a new name', 'name');
Could anyone tell me why this code isn't working? I'm at the "Confirm the Ending" on Bonfire.
Joris Labie
@labiej
Aug 03 2015 12:28
Nepherius
@Nepherius
Aug 03 2015 12:29
@EliasJorgensen seems it always returns false
Omar
@oab00
Aug 03 2015 12:29
@labiej congratz!
jovandamjanovic
@jovandamjanovic
Aug 03 2015 12:30
@EliasJorgensen If either argument of substring is less than 0 or is NaN, it is treated as if it were 0.
So your function in the example compares He h with name and returns false.
JMitnik
@JMitnik
Aug 03 2015 12:32
On using JSON api: if I have have an url from mashape, like this one:
curl -X POST --include 'https://andruxnet-random-famous-quotes.p.mashape.com/cat=movies' \
  -H 'X-Mashape-Key: 0EibPOXOfcmshAOMRpAVN7cEnQb0p1IB1G7jsnb5MaknTa7hVE' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Accept: application/json'
@JMitnik
do I put that in the $.getjson() ?
Because if I only use the https url, I am not authorized, so I need the key, but my code fails when I insert this in my getjson function
JMitnik
@JMitnik
Aug 03 2015 12:37
@labiej, thank you
Elias Jørgensen
@EliasJorgensen
Aug 03 2015 12:40
I have tried using "str.length - target.length" instead, but then it uses "as to give me a new " as the substring instead
Joris Labie
@labiej
Aug 03 2015 12:40
I'm quite sure mashape api's should have something like an argument similar too url.com/api.php?query=request&key=APIKEY
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 12:42
@JMitnik use $.ajax insted of $.getJSON and set the header in the beforeSend function
jovandamjanovic
@jovandamjanovic
Aug 03 2015 12:42
The arguments for substring are the beginning and the end of the cutoff point so you should give it either (str.length-target.length, str.length) or, because it supports less arguments, just the (str.length-target.length) for simplicity's sake ^^
Ozy Design & Software
@OzySky
Aug 03 2015 12:50
any ideas for Bonfire: Arguments Optional?
CamperBot
@camperbot
Aug 03 2015 12:50
type bonfire name
to get some info on that bonfire here
Ozy Design & Software
@OzySky
Aug 03 2015 12:50
bonfire Arguments Optional
CamperBot
@camperbot
Aug 03 2015 12:50

:fire:Bonfire: Arguments Optional :link:

function add() {
  return false;
}

add(2,3);

Create a function that sums two arguments together. If only one argument is provided, return a function that expects one additional argument and will return the sum.

for more info: bf details bf links bf script bf wiki bf spoiler

Ozy Design & Software
@OzySky
Aug 03 2015 12:50
bf details
CamperBot
@camperbot
Aug 03 2015 12:50

:fire:Bonfire: Arguments Optional :link:

function add() {
  return false;
}

add(2,3);

Create a function that sums two arguments together. If only one argument is provided, return a function that expects one additional argument and will return the sum.
For example, add(2, 3) should return 5, and add(2) should return a function that is waiting for an argument so that <code>var sum2And = add(2); return sum2And(3); // 5</code>
If either argument isn't a valid number, return undefined.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Global Function Object,
Arguments object


  • bonfire info for more info
  • bonfire links
  • bonfire script for the script
  • bonfire spoiler for some clues on how to solve it
  • bonfire wiki for related info from the wiki
jovandamjanovic
@jovandamjanovic
Aug 03 2015 12:51
@ozydesign you make a function that checks the number of arguments. If it receives two arguments it returns a result, if it's only one it returns another function. :)
Ozy Design & Software
@OzySky
Aug 03 2015 12:52
but how does that function receive the second argument?
This message was deleted
CamperBot
@camperbot
Aug 03 2015 12:52
Coming Soon! We're working on it!
ronald
@ronstarcool
Aug 03 2015 12:53
return second(a);
second(3);
not sure
Ozy Design & Software
@OzySky
Aug 03 2015 12:53
bonfire spoiler
CamperBot
@camperbot
Aug 03 2015 12:53
[0] Create a function that sums two arguments together. If only one argument is provided, return a function that expects one additional argument and will return the sum.
jovandamjanovic
@jovandamjanovic
Aug 03 2015 12:54
The second function requires another argument
For instance:
function sum() {
  a=arguments[0], b=arguments[1];
  if (a && b) {
    return a + b;
  } 
  if (a && !b) {
    return function (x) {
      return a+x;
    }
  }
  return undefined;
}
This might need some tweaking if I got the syntax wrong along the way but I think the point comes across clear. ^^
Chirag Patel
@CPatel217
Aug 03 2015 13:03
for those peeps that know regex
wats teh difference between the word boundary character \b and using the anchors ^(expression)$
Ozy Design & Software
@OzySky
Aug 03 2015 13:07
word boundry could be in the middle of the word for eg
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:09
This article explains it somewhat http://www.rexegg.com/regex-boundaries.html
But, from what I can glimpse, ^ and $ are boundaries of the entire string (or anchors) while \b is a boundary of individual words inside the string.
Chirag Patel
@CPatel217
Aug 03 2015 13:14
@jovandamjanovic thanks for the article
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:19
No problem :)
Bill Zerega
@dedicatedfuture
Aug 03 2015 13:20
good morning
can anyone help me on advanced bonfire inventory update?
CamperBot
@camperbot
Aug 03 2015 13:20
type bonfire name
to get some info on that bonfire here
that is my code
i am clearing all the tests but not deep equallying 2 of the tests
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:22
bonfire inventory
CamperBot
@camperbot
Aug 03 2015 13:22
can't find a bonfire called inventory
Bill Zerega
@dedicatedfuture
Aug 03 2015 13:22
bonfire inventory update
CamperBot
@camperbot
Aug 03 2015 13:22
can't find a bonfire called inventory update
Bill Zerega
@dedicatedfuture
Aug 03 2015 13:22
bonfire Inventory Update
CamperBot
@camperbot
Aug 03 2015 13:22
can't find a bonfire called inventory update
Bill Zerega
@dedicatedfuture
Aug 03 2015 13:22
is camperbot just a troll?
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:22
Looking into it now
It is a WIP
Bill Zerega
@dedicatedfuture
Aug 03 2015 13:23
ah
any help on my code?
Matthew Barber
@Honno
Aug 03 2015 13:24
Hey guys, I notice both FCC and CodeAcademy use single quotes (') and double quotes (") seemingly interchangably... is there a difference in jQuery?
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 13:25
@Honno no, it's the same
Matthew Barber
@Honno
Aug 03 2015 13:25
ah thanks @vincepandolfo
Joseph Chananga Myalla
@sojelee
Aug 03 2015 13:25
help bonfire arguments optional
CamperBot
@camperbot
Aug 03 2015 13:25
no wiki entry for: bonfire arguments optional
:pencil: click here to create one now!after creating your page type update to reload it here
Matthew Barber
@Honno
Aug 03 2015 13:25
guess they use " for string stuff and ' for everything else just so it looks pretty
Joseph Chananga Myalla
@sojelee
Aug 03 2015 13:26
help please arguments optinal in bonfire
CamperBot
@camperbot
Aug 03 2015 13:26
no wiki entry for: please arguments optinal in bonfire
:pencil: click here to create one now!after creating your page type update to reload it here
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:28
@dedicatedfuture I think I found the problem, looking for the solution
Found it!
Joseph Chananga Myalla
@sojelee
Aug 03 2015 13:30
guys any one done with bonfire arguments optional please
CamperBot
@camperbot
Aug 03 2015 13:30
type bonfire name
to get some info on that bonfire here
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:30
in line 11 you're adding the name of the product in the second array to the number of the product in the first array. Edit the arr2[i1][1] to arr2[i1][0] and it will pass ^^
Jorge Almeida
@Jorgixhallo
Aug 03 2015 13:30
bonfire Inventory Update
CamperBot
@camperbot
Aug 03 2015 13:30
can't find a bonfire called inventory update
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:30
@sojelee I can try to help you
What seems to be your problem?
Bill Zerega
@dedicatedfuture
Aug 03 2015 13:33
wow great catch @jovandamjanovic
thanks a lot man
Dayne Wright
@daynewright
Aug 03 2015 13:34
Can anyone help me through how to tackle bonfire steamroller?
Joseph Chananga Myalla
@sojelee
Aug 03 2015 13:34
@jovandamjanovic get the new function when only one argument is found
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:34
nps ^^
@sojelee Can you post your source here so I can see what you have?
@Daynewr you should use reduce() and a little bit of recursion
Dayne Wright
@daynewright
Aug 03 2015 13:39
@jovandamjanovic Can you help me understand recursion? I am not sure how to approach that.
Jorge Almeida
@Jorgixhallo
Aug 03 2015 13:42
This message was deleted
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:45
function flatten(someArray) {
  return someArray.reduce(
    if (currentMember.some(Array.isArray)) { //you check if some of the members in the current array are arrays themselves
      currentMember = flatten(currentMember); //here you call it recursively
    }
    //here goes logic that concats all the members together
  );
}
Damn... hope I didn't make it worse ^^' tried not to explicitly solve it for you
Joseph Chananga Myalla
@sojelee
Aug 03 2015 13:46
@jovandamjanovic can i post here
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:46
Ofc :)
Joseph Chananga Myalla
@sojelee
Aug 03 2015 13:47

function add(){
var arg0, arg1;
if(arguments.length==2) {
arg0=parseInt(arguments[0]);
arg1=parseInt(arguments1);
}else{

arg1 = function(){ new Function('a','return a');
};

}

if(isNaN(arg0) || isNaN(arg1)){
return " undefined ";} else{
return arg0+arg1;
}
}

Dayne Wright
@daynewright
Aug 03 2015 13:47
@jovandamjanovic thanks. I will see if I can work with it :)
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:48
@Daynewr np... hope I didn't make it more confusing though ^^'
@sojelee arg0 should always be arguments[0] and in your else block you should return the function, not assign it to arg1
Dayne Wright
@daynewright
Aug 03 2015 13:50
@jovandamjanovic I haven’t seen reduce() written that way. Without the reduce(function(current,index,array){}) type format.
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:51
so, take the arg0 = parseInt(arguments[0]) out of the if and change the else block to return function...etc
@Daynewr It isn't written like that, it is wrong on purpose because it wasn't relevant for my 'example'
Like I said, I tried to write as little as possible to avoid explicitly solving it for you ^^'
Dayne Wright
@daynewright
Aug 03 2015 13:52
@jovandamjanovic Got it.
Will see what I can do
I am understanding reduce, map, filter better but the recursion idea still messes me up.
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:54
Recursion is a relatively complex but powerful process that can make your life easier or make it hell
I assume you've done the Fibonacci bonfire?
CamperBot
@camperbot
Aug 03 2015 13:55
type bonfire name
to get some info on that bonfire here
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:55
That one is aimed at getting you to work with recursion
bonfire fibonacci
CamperBot
@camperbot
Aug 03 2015 13:55

:fire:Bonfire: Sum All Odd Fibonacci Numbers :link:

function sumFibs(num) {
  return num;
}

sumFibs(4);

Return the sum of all odd Fibonacci numbers up to and including the passed number if it is a Fibonacci number.

for more info: bf details bf links bf script bf wiki bf spoiler

Dayne Wright
@daynewright
Aug 03 2015 13:56
I see. I didn’t complete it with recursion.
function sumFibs(num){
    var totalCount = 0;
    var currNum = 0;
    var nextNum = 0;

    for(var i = 1; i <= num; i = currNum + nextNum){
        if(i % 2) {
            totalCount += i;
            console.log('totalCount: ' +totalCount);
        }
        currNum = nextNum;
        console.log('currNum: ' + currNum);
        nextNum = i;
        console.log('nextNum: ' + nextNum);
    }

  return totalCount;
}

sumFibs(5);
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:58
Ah, i see :)
Stein Gee
@Stiino0
Aug 03 2015 13:58
Hi Guys, I want some advice. I can't seem to figure out why code A works and code B (which I find the same) doesn't. Can I post? http://www.freecodecamp.com/challenges/bonfire-slasher-flick
jovandamjanovic
@jovandamjanovic
Aug 03 2015 13:58
@Stiino0 Go ahead, that's why we're here ;)
Stein Gee
@Stiino0
Aug 03 2015 13:58
this works:
function slasher(arr, howMany) {
  arr.splice(0,howMany);
  return arr;
}

slasher([1, 2, 3], 2);
This doesn't:
function slasher(arr, howMany) {
  return arr.splice(0,howMany);
  //return arr;
}

slasher([1, 2, 3], 2);
Dayne Wright
@daynewright
Aug 03 2015 13:59
@jovandamjanovic Can you show me how you would complete the fib bonfire with recursion?
CamperBot
@camperbot
Aug 03 2015 13:59
type bonfire name
to get some info on that bonfire here
Stein Gee
@Stiino0
Aug 03 2015 14:00
"A" returns [3]
jovandamjanovic
@jovandamjanovic
Aug 03 2015 14:00
@Daynewr absolutely, just give me a sec
Stein Gee
@Stiino0
Aug 03 2015 14:00
while "B" returns [1, 2]
I thought "B" was a better version of "A", slightly smaller and thus perhaps faster? :(
Joseph Chananga Myalla
@sojelee
Aug 03 2015 14:00
@jovandamjanovic what is the structure of the function on the else part
jovandamjanovic
@jovandamjanovic
Aug 03 2015 14:01
@Stiino0 the splice function returns the 'chopped off' portion and the original array remains. So the first example splices the array and then returns what's left while th esecond returns the return value of the function (i e the bits that you spliced off)
@sojelee something like:
retun function(x) {
  return arg0 + x;
}
Stein Gee
@Stiino0
Aug 03 2015 14:02
oh ok, that's just how the splice function works then? That's a neat trick if necessary for certain purposes
thanks @jovandamjanovic !
CamperBot
@camperbot
Aug 03 2015 14:02
stiino0 sends karma to jovandamjanovic :thumbsup: :sparkles: :sparkles:
Stein Gee
@Stiino0
Aug 03 2015 14:03
Yeah, what Camperbot says :)
Omar
@oab00
Aug 03 2015 14:03
@Stiino0 https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
tells you what a function does and what it returns :)
Stein Gee
@Stiino0
Aug 03 2015 14:04
I know of the moz doc on splice, that's why I used it for this Bonfire :D
CamperBot
@camperbot
Aug 03 2015 14:04
type bonfire name
to get some info on that bonfire here
Stein Gee
@Stiino0
Aug 03 2015 14:04
however I'll reread it to see if this thing is also in there! ;)
jovandamjanovic
@jovandamjanovic
Aug 03 2015 14:05
@Stiino0 it says so: Returns: An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.
Stein Gee
@Stiino0
Aug 03 2015 14:05

Indeed: Returns

An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.

jovandamjanovic
@jovandamjanovic
Aug 03 2015 14:05
And np :)
Stein Gee
@Stiino0
Aug 03 2015 14:05
oh you just said the same haha
Yep, just now noticed it :)
So far, I've only looked up the structure of what I think I should use for the bonfires, then have my way with it and test things out. Since I didn't read further I didn't see the return section... So sorry, thanks for helping!
jovandamjanovic
@jovandamjanovic
Aug 03 2015 14:07
@Daynewr here's a simple example of recursion, to find the n-th member of the fibonacci sequence:
function fib(n) {
  if (n === 0 || n === 1) { //you must always remember to provide an exit for the recursion
    return 1;
  }
  return fib(n-1) + fib(n-2); //the function calls it self applying recursion here
}
@Stiino0 no worries, like I said, we're here to help :)
There are no stupid questions
Stein Gee
@Stiino0
Aug 03 2015 14:08
I like it :p I know, I just hadn't posted yet in the help section. Cya later! (I hope not so fast in the help section :))
Dayne Wright
@daynewright
Aug 03 2015 14:09
@jovandamjanovic thanks
Santiago Melo
@smeloa
Aug 03 2015 14:35

Hi, can anyone help me with Bonfire: Make a Person I am completely stuck.

Code is:

var Person = function(firstAndLast) {

  var nameStr = firstAndLast;

  var fullName;
  var firstName;
  var lastName;

  this.setFullName = function(nameStr) {
    var fullName = firstAndLast;
    return fullName;
  };

  this.setFirstName = function(nameStr) { 
    var firstName = nameStr.substr(0,nameStr.indexOf(' '));
    return firstName;
  };

  this.setLastName = function(nameStr) { 
    var lastName = nameStr.substr(0,nameStr.indexOf(' '));
    return lastName;
  };

  this.getFullName = function(fullname) {
    return fullName;
  };

  this.getFirstName = function(firstName) { 
    return firstName;
  };

  this.getLastName = function(lastName) { 
    return lastName;
  };


};

var bob = new Person('Bob Ross');
bob.setFullName();

Thanks!

Feners4
@Feners4
Aug 03 2015 14:35
can i get help with ..http://codepen.io/Feners4/pen/EjONEe
i need help with why i'm not getting all the users I should and how to get their profile pic..
Joris Labie
@labiej
Aug 03 2015 14:39
@Feners4 because you don't extract it? Don't know how those preprocessors work$
Feners4
@Feners4
Aug 03 2015 14:44
@labiej my problem seems to be iterating over my arrays..
Joris Labie
@labiej
Aug 03 2015 14:45
I don't know the frameworks so can't read the code
Jacques de Reynal
@jdr972
Aug 03 2015 14:57
Hey guys, was just wondering if this line of code was right and the beta is just bugged or do I have a problem in my code
' $('.well:nth-child(2)').addClass('animated bounce'); '
$('.well:nth-child(2)').addClass('animated bounce');
Jorge Almeida
@Jorgixhallo
Aug 03 2015 14:58
@jdr972 class name can have a spaces?
im not sure
Because when you want multiple classes you just do class="xxxx yyyyy zzzzz" and i don't know if that will mess up or not
Jacques de Reynal
@jdr972
Aug 03 2015 15:00
They can't have spaces
I'm adding two different classes
My problem is they don't apply to second child and I think they are supposed to
That's what it says on the waypoint
Screenshot
Moisés Man
@moigithub
Aug 03 2015 15:08
@Feners4 what this does ??
$scope.$apply();
Feners4
@Feners4
Aug 03 2015 15:09
@moigithub it applies changes to my scope so the data can be displayed..
@moigithub idk why, everytime I run my app the list is different, sometimes it displays the full list I need, but when I run again, it goes back to fragmented list..
Jorge Almeida
@Jorgixhallo
Aug 03 2015 15:13
@jdr972 iI think it should work. can you link me the waypoint?
EDIT: got it already
Omar
@oab00
Aug 03 2015 15:17
@Feners4 might be because jQuery and Angular aren't playing nice together
look into implementing Angular's $http instead of jQuery's $.getJSON
Jacques de Reynal
@jdr972
Aug 03 2015 15:21
@Jorgixhallo did you get it working?
for me it just bounces the whole wells
Jorge Almeida
@Jorgixhallo
Aug 03 2015 15:25
@jdr972 yes
$('.well :nth-child(2)').addClass('animated bounce');
Only passes with the space
Jacques de Reynal
@jdr972
Aug 03 2015 15:26
what is that } doing there though
typo?
Jorge Almeida
@Jorgixhallo
Aug 03 2015 15:26
I copied a little more than intended
yes
Jacques de Reynal
@jdr972
Aug 03 2015 15:26
Ok
So for you too it just bounces the wells
Jorge Almeida
@Jorgixhallo
Aug 03 2015 15:27
it bounces everything
all targets
*the div
Jacques de Reynal
@jdr972
Aug 03 2015 15:27
Same for me. Guess it's a beta issue, thanks for the help!
Jorge Almeida
@Jorgixhallo
Aug 03 2015 15:28
when I read the second element of each i also tried to put the classes on the buttons, but it didn't work
Jacques de Reynal
@jdr972
Aug 03 2015 15:29
I've tried that as well
$('#target3').addClass('animated bounce'); but it works with this one
Jorge Almeida
@Jorgixhallo
Aug 03 2015 15:31
@jdr972 They are still developing it. Just report the bug on github if you want xD
Jacques de Reynal
@jdr972
Aug 03 2015 15:31
I will, I just came here because I figured I might have made a mistake
Jelani Thompson
@JelaniThompson
Aug 03 2015 15:32
Hey guys!
So I'm back to working on the Truncate a string bonfire
But I'm having some issues
function truncate(str, num) {

  var truncated_string;

  if (str.length > num) {
   truncated_string = str.slice(0, num - 3);
   truncated_string += "...";
  } else if (str.length == num) {
    console.log("Did not truncate string");
  }

  return truncated_string;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
It's passing the first test but giving me two more error messages
assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length) === 'A-tisket a-tasket A green and yellow basket', 'should not truncate if string is = length');should not truncate if string is = length
and
assert.strictEqual(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2), 'A-tisket a-tasket A green and yellow basket', 'should not truncate if string is < length');should not truncate if string is < length: expected undefined to equal 'A-tisket a-tasket A green and yellow basket'
Would anyone be able to clarify what those error messages mean?
Thank you!
Jorge Almeida
@Jorgixhallo
Aug 03 2015 15:35
@JelaniThompson what are you returning if the string is <= 'num'?
even if you don't change the original string you need to return it right?
Jelani Thompson
@JelaniThompson
Aug 03 2015 15:36
Oh true lol
Thank you so much Jorg!
It finally got through :)
Omar
@oab00
Aug 03 2015 15:57
@Feners4 did u get it to work ?
Joseph Chananga Myalla
@sojelee
Aug 03 2015 16:00
@jovandamjanovic thankx friend will keep on trying
Paul Dynowski
@pdynowski
Aug 03 2015 16:12
can anyone give me some advice on the symmetric differences bonfire?
CamperBot
@camperbot
Aug 03 2015 16:12
type bonfire name
to get some info on that bonfire here
Paul Dynowski
@pdynowski
Aug 03 2015 16:13
This message was deleted
This message was deleted
bonfire symmetric difference
CamperBot
@camperbot
Aug 03 2015 16:14
can't find a bonfire called symmetric differences
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:25
@pdynowski what have you tried so far?
I suggest using reduce like the bonfire suggests
CamperBot
@camperbot
Aug 03 2015 16:25
type bonfire name
to get some info on that bonfire here
Dayne Wright
@daynewright
Aug 03 2015 16:25
Ok..I still need help solving steam roller with reduce and recursion. Just not getting it.
Tom Sun
@tomsun100
Aug 03 2015 16:26
bonfire Pairwise
CamperBot
@camperbot
Aug 03 2015 16:26
can't find a bonfire called pairwise
Tom Sun
@tomsun100
Aug 03 2015 16:26
bonfire make a person
CamperBot
@camperbot
Aug 03 2015 16:26
can't find a bonfire called make a person
Tom Sun
@tomsun100
Aug 03 2015 16:26
bonfire reverse a string
CamperBot
@camperbot
Aug 03 2015 16:26

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.

for more info: bf details bf links bf script bf wiki bf spoiler

Paul Dynowski
@pdynowski
Aug 03 2015 16:27
@ngalluzzo i'm using reduce. passing in an empty array ([]) when it starts. can't get past the first loop, because my array type is getting changed to a number type, and i don't understand why
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:27
what are you passing through the reduce? args? or are you using arguments
Paul Dynowski
@pdynowski
Aug 03 2015 16:28
@ngalluzzo concatted all the args into one array
passing that array into reduce
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:29
I tried that at first two, but that isn’t going to work because you need to compare one array to the next coming one
at first too*
Paul Dynowski
@pdynowski
Aug 03 2015 16:29
don't seem to have backquotes on my keyboard, or i'd post code
KieronDowie
@KieronDowie
Aug 03 2015 16:30
`
Paul Dynowski
@pdynowski
Aug 03 2015 16:30
@ngalluzzo why? we're just looking for unique values. so long as the value doesn't exist in the array we're passing as prev, then we push it. otherwise, we don't
KieronDowie
@KieronDowie
Aug 03 2015 16:31
Copy that. :P
Paul Dynowski
@pdynowski
Aug 03 2015 16:31
@KieronDowie thanks
dc
@dcsan
Aug 03 2015 16:31
help format
CamperBot
@camperbot
Aug 03 2015 16:31

:pencil: code formatting

Steps to format your code for pasting in the chat room.

Inline code

This an inline `<paste code here>` code formatting.

^single backtick at start and end around the inline code.

 

Code Block

``` ⇦ Type 3 backticks, 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

dc
@dcsan
Aug 03 2015 16:31
@pdynowski
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:31
@pdynowski let’s take one of their complex tests for example [1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]
dc
@dcsan
Aug 03 2015 16:31
you can find the keys on the wiki page above
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:31
with your solution you would just get 4, right?
Liz Rezes
@queenlizo
Aug 03 2015 16:32
I'm doing Confirm the Ending, and this is working for most of the tests except this one:
assert.strictEqual(end('He has to give me a new name', 'name'), true, 'should equal true if target equals end of string');should equal true if target equals end of string: expected false to equal true
Anyone have any ideas?
function end(str, target) { 
  var word = str.split('');
  var lastLetter = word[word.length - 1];
  var targetArray = [];
  if (lastLetter === target) {
    return true;
   } else {
     return false;
   }
  return str;
}

end('Bastian', 'n');
Paul Dynowski
@pdynowski
Aug 03 2015 16:32
@ngalluzzo ....yes. bugger.
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:32
however what they want is this…
[1, 1, 2, 5], [2, 2, 3, 5] => reduce to [1,3]
[1,3], [3, 4, 5, 5] => reduce to [1,4,5]
even though 5,5 repeat in that last array, it exists in one array but not the other
Tristanto
@rustyworks
Aug 03 2015 16:34
Zomg!
  return movieLists.map(function (categories) {
    return categories.videos.map(function (video) {
      var predicate = function (item) {
        return item.width === 150;
      };
      url = video.boxarts.filter(predicate).map(function (n) { return n.url; });

      return url.map(function (url1) {
        return { id: video.id, title: video.title, boxart: url1 };
      });
    }).concatAll();
  }).concatAll();
Paul Dynowski
@pdynowski
Aug 03 2015 16:34
@ngalluzzo ok. thank you. i have to go think, now.
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:35
@pdynowski hah yep, good luck! Feel free to PM me if you run into any roadblocks, it sounds like we headed the exact same path
Spencer
@lopez567
Aug 03 2015 16:35
Could somebody explain to me what I'm trying to return with the symmetric difference challenge. I'm not understanding why ([1, 2, 5], [2, 3, 5], [3, 4, 5]) should return [1,4,5]
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:35
@lopez567 I just explained above

@ngalluzzo
however what they want is this…

[1, 1, 2, 5], [2, 2, 3, 5] => reduce to [1,3]
[1,3], [3, 4, 5, 5] => reduce to [1,4,5]

even though 5,5 repeat in that last array, it exists in one array but not the other

Spencer
@lopez567
Aug 03 2015 16:38
Ohhhhhh okay
Anthony MacMahon
@SansPulp
Aug 03 2015 16:38
Does anyone have some documentation to look at for how to solve Return the largetst number in arrays bonfire? I'm not even sure I know where to start
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:40
Loop through all arrays
Loop through each number in the array
Push the largest number to a new array
Anthony MacMahon
@SansPulp
Aug 03 2015 16:47
@ngalluzzo Was that for me?
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:47
yep sorry :)
Anthony MacMahon
@SansPulp
Aug 03 2015 16:51
@ngalluzzo So would that involve making a for loop inside of another for loop, then pushing each largest number to a new array?
Nic Galluzzo
@ngalluzzo
Aug 03 2015 16:55
that’s right, you can chain loops like that @SansPulp
you could try something like this
for(var i =0; i<arr.length; i++) {
    var largestNumber = 0;
    for(var j=0; j<arr[i].length; j++) {
    }
}
Ryan Malm
@Rybar
Aug 03 2015 16:56
Any React dev's around I can bother for a couple minutes?
M Used
@mildused
Aug 03 2015 17:07
@Rybar try me
Matthew Barber
@Honno
Aug 03 2015 17:07
Hey, why does CodeAcademy always add a space (" ") as an extra element, ie"Hi, I am" + " " + name. rather than "Hi, I am " + name.
Is that a best practice? Why?
M Used
@mildused
Aug 03 2015 17:07
No, it's just to show you it's there, otherwise you might skip over it
Matthew Barber
@Honno
Aug 03 2015 17:07
Maybe I'm just lazy, to me it doesn't seem a big deal
Yeah prob good for us newbies
ty
M Used
@mildused
Aug 03 2015 17:08
No probs
willamgriffin
@willamgriffin
Aug 03 2015 17:08
can someone tell me what while(x-- > 0) dose in javascript?
Tristanto
@rustyworks
Aug 03 2015 17:08
@ngalluzzo use map reduce :D
Nic Galluzzo
@ngalluzzo
Aug 03 2015 17:09
@rustyworks yes that’s how I solved it but that’s not taught yet at that point
M Used
@mildused
Aug 03 2015 17:09
@willamgriffin can you type as code?
Elias Jørgensen
@EliasJorgensen
Aug 03 2015 17:09
"Bonfire: Chunky Monkey" Could anyone explain what i have to do in this?
The description doesn't make sense to me..
CamperBot
@camperbot
Aug 03 2015 17:09
can't find a bonfire called chunky monkey could anyone explain what i have to do in thisthe description doesnt make sense to me
Elias Jørgensen
@EliasJorgensen
Aug 03 2015 17:09
Bonfire: Chunky monkey
CamperBot
@camperbot
Aug 03 2015 17:09

:fire:Bonfire: Chunky Monkey :link:

function chunk(arr, size) {
  // Break it up.
  return arr;
}

chunk(['a', 'b', 'c', 'd'], 2);

Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.

for more info: bf details bf links bf script bf wiki bf spoiler

willamgriffin
@willamgriffin
Aug 03 2015 17:09
while (num-- > 0)
Tristanto
@rustyworks
Aug 03 2015 17:09
I refactor my code after I got the functional javascript lesson :D
M Used
@mildused
Aug 03 2015 17:10
@willamgriffin It subtracts 1 from n. then compares if it's greater than 0
Nic Galluzzo
@ngalluzzo
Aug 03 2015 17:10
same, went back and did practically every bonfire with map reduce filter
CamperBot
@camperbot
Aug 03 2015 17:10
type bonfire name
to get some info on that bonfire here
M Used
@mildused
Aug 03 2015 17:10
so if num is 1 before start, it won't run the while loop, @willamgriffin
willamgriffin
@willamgriffin
Aug 03 2015 17:10
ah thanks
Elliescode
@EllieAdam
Aug 03 2015 17:11
morning!
willamgriffin
@willamgriffin
Aug 03 2015 17:16
intresting how while (num-1 > 0) works differently though
JMitnik
@JMitnik
Aug 03 2015 17:23
Is there a way to make a https://twitter.com/intent/tweet?text= refer to a certain ID h2 in my html?
So tweet a dynamic text (which has an id of #specialid)
Nic Galluzzo
@ngalluzzo
Aug 03 2015 17:24
@JMitnik use jQuery to grab the text and append to the end of the URL
JMitnik
@JMitnik
Aug 03 2015 17:25
@ngalluzzo so in jquery, grap the url, append the text to the end of the url, and save it to the url?
Nic Galluzzo
@ngalluzzo
Aug 03 2015 17:26
It’d be easier if you just define the URL directly from jQuery too, then append the entire URL to the link’s href property
var url = ‘https://twiter……’/ + h2Text
$(‘#elem’).prop()
JMitnik
@JMitnik
Aug 03 2015 17:28
@ngalluzzo Gotcha, thanks :) !
Nic Galluzzo
@ngalluzzo
Aug 03 2015 17:29
any time :)
Luís Melo
@luisfmelo
Aug 03 2015 17:38
hey guys
about bonfire (objects)
CamperBot
@camperbot
Aug 03 2015 17:38
you need to ask about @someone!
Craig Morrison
@frogmorton
Aug 03 2015 17:46
@ngalluzzo calculating the fibonacci series is obviously possible, but the numbers get very big, very fast. I have a small snippet that will give the fibonacci value if you pass it n, the nth position in the series... I don't know how to utilize this to generate the array I need for #30. The position in the series has NOTHING to do with the values of the fib numbers
Nic Galluzzo
@ngalluzzo
Aug 03 2015 17:47
that’s right the position has nothing to do with it, it’s UP to the VALUE of the number you get
so if you’re given 1830 don’t calculate 1830 sequences, calculate the numbers UP TO 1830 :)
Craig Morrison
@frogmorton
Aug 03 2015 17:49
That sounds like the upper limit on a loop
depending on how the limit is set up
oops... the *loop is set up
Nic Galluzzo
@ngalluzzo
Aug 03 2015 17:50
correct
John Chau
@ydjjabt
Aug 03 2015 17:54
@labiej
you are partially correct but his code is a little bit wrong and i think his logic is as follow in my code here below.
 function arrayFilter(value){
        for(var i = 0; i < largeArray.length; i++){
        return value === arr1[i];
    }
Alex
@awulkan
Aug 03 2015 17:54
Can anyone help me with the Seek and Destroy bonfire?
Terrell Vest
@MirPresT
Aug 03 2015 17:54
John Chau
@ydjjabt
Aug 03 2015 17:55
@labiej you are partially correct but his code is a little bit wrong and i think his logic is as follow in my code here below.
function arrayFilter(value){
        for(var i = 0; i < largeArray.length; i++){
        return value === largeArray[i];
    }
Alex
@awulkan
Aug 03 2015 17:55
@MirPresT What do you mean, isn't this the official help section?
Joris Labie
@labiej
Aug 03 2015 17:56
@ydjjabt hmm that's a while ago, the question you are referring too, isn't it?
Terrell Vest
@MirPresT
Aug 03 2015 17:56
it is but that chat is specific to bonfires and might give you a better chance at finding help specific to bonfires - @AlexWulkan
Alex
@awulkan
Aug 03 2015 17:57
@MirPresT I've already "solved" the bonfire, but I did it in a bad way. I need help making my code dynamic.
CamperBot
@camperbot
Aug 03 2015 17:57
type bonfire name
to get some info on that bonfire here
Alex
@awulkan
Aug 03 2015 17:58
bonfire Seek and Destroy
CamperBot
@camperbot
Aug 03 2015 17:58

: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.

for more info: bf details bf links bf script bf wiki bf spoiler

John Chau
@ydjjabt
Aug 03 2015 17:58
@labiej yeah, his logic is wrong because he doesnt know what to do with the largest array out of two array lol
my code is wrong too because i misunderstand his logic/goal
his syntax is correct
Joris Labie
@labiej
Aug 03 2015 17:58
Whoa I'm not sure I even responded to this question
Terrell Vest
@MirPresT
Aug 03 2015 17:59
@AlexWulkan code ?
Alex
@awulkan
Aug 03 2015 17:59
@MirPresT
function destroyer(arr) {

  var arg = [];
  // Fills arg with arguments[1], arguments[2], arguments[n]
  // How can I make this dynamic? Do I even need it?
  for(var i = 1; i < arguments.length; i++){
    arg.push(arguments[i]);
  }

  var survived = arguments[0].filter(function(value, index){

    // Hardcoded what to check. How can I make it dynamic?
    return value != arg[0] && value != arg[1];
  });
  return survived;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Juan David Pastas
@juanpastas
Aug 03 2015 18:11
@AlexWulkan
function destroyer(arr) {
  var tail = [].slice.call(arguments, 1);
  // Remove all the values
  return arr.filter(function(e){return tail.indexOf(e) == -1;});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Feners4
@Feners4
Aug 03 2015 18:43
guys any help with why my usernames list is not complete on http://codepen.io/Feners4/pen/EjONEe
also, why are the display pics not showing?..
Marie Pelletier
@Marie000
Aug 03 2015 18:45
Is anyone able to explain the array.reduce() function? I understand what it is supposed to do, but I don't understand how to use it and what parameters it takes. I read and re-read the mozilla page and I don't understand :worried:
Joris Labie
@labiej
Aug 03 2015 18:48
@Marie000 it is a difficult part. Eventually you'll understand it
Some people benefit from redoing bonfires using functional programming. Most can be done very elegant that way
CamperBot
@camperbot
Aug 03 2015 18:48
type bonfire name
to get some info on that bonfire here
Oliver
@Dadsaster
Aug 03 2015 18:49
@Marie000 reduce returns only one value - it applies the function to the first to items in an array -> reduces them to one value and then does it again until there in only one value left
Nic Galluzzo
@ngalluzzo
Aug 03 2015 18:49
@Marie000 the easiest way to start understanding it is with a simple process like this one…
[0, 1, 2, 3, 4].reduce(function (total, currentNumber) {
      console.log(’TOTAL!!!’, total);
    console.log(‘CURRENT NUMBER!!!’, currentNumber)
       return total += currentNumber
  }, 0);
total is your starting value, and each time you iterate through an element in arr, total will become whatever you return
Oliver
@Dadsaster
Aug 03 2015 18:50
[0, 1, 2, 3, 4].reduce(function(previousValue, currentValue) {
    return previousValue + currentValue;
}
0+1 -> 1+2 -> 3+3 -> 6 + 4 -> 10
Marie Pelletier
@Marie000
Aug 03 2015 18:51
Okay, it finally worked but I defined by function first, and then used it with reduce, like this:
function sumAll(arr) {
  //get min value of arr
  var min = Math.min.apply(Math,arr);
  //get max value of arr
  var max = Math.max.apply(Math,arr);
  //create new array
  var newArray = [];
  //push numbers from min to max (for loop)
  for (x=min; x<=max; x++){
    newArray.push(x);
  }
  //reduce()
  function addition(a,b) {
    return a + b;
  }
 var reducedArray = newArray.reduce(addition);
 return reducedArray;
}

sumAll([1, 4]);
so I take it the reduce function will assume "a" is the previous value and "b" is the current value, right?
Joris Labie
@labiej
Aug 03 2015 18:52
@Feners4 try debugging using console.log
if that doesn't work start with a single user, if that works add the loop
Oliver
@Dadsaster
Aug 03 2015 18:53
@Marie000 you can name them anything - so yes
@Marie000 - you could write it like this...
function sumAll(arr) {
  //get min value of arr
  var min = Math.min.apply(Math,arr);
  //get max value of arr
  var max = Math.max.apply(Math,arr);
  //create new array
  var newArray = [];
  //push numbers from min to max (for loop)
  for (x=min; x<=max; x++){
    newArray.push(x);
  } 
  }
 return newArray.reduce(function(a, b) {
   return a + b;
});
}

sumAll([1, 4]);
Dayne Wright
@daynewright
Aug 03 2015 18:56
I am at a lose with steamroller if anyone wants to help. Just can’t seem to get a grasp on it still.
Oliver
@Dadsaster
Aug 03 2015 18:58
@Daynewr do you understand how to flatten an array?
var flattened = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) {
  return a.concat(b);
});
// flattened is [0, 1, 2, 3, 4, 5]
Dayne Wright
@daynewright
Aug 03 2015 19:00
@Dadsaster nope. That is what I was struggling with actually. Thanks
Marie Pelletier
@Marie000
Aug 03 2015 19:00
ok, I still tend to do one thing at a time, but I should practice making my code shorter.
Dayne Wright
@daynewright
Aug 03 2015 19:00
Let me look over that and see if I can make a little traction.
BoyanP
@BoyanP
Aug 03 2015 19:01
can anyone help me with the no repeats please bonfire?
CamperBot
@camperbot
Aug 03 2015 19:01
type bonfire name
to get some info on that bonfire here
Oliver
@Dadsaster
Aug 03 2015 19:01
@Marie000 nothing wrong with how you wrote it - you will often see the anonymous function version like I wrote. Little by little...
Dayne Wright
@daynewright
Aug 03 2015 19:02
@Dadsaster So on your reduce(function(a,b){}) a is the current and b is the next?
Oliver
@Dadsaster
Aug 03 2015 19:03
@BoyanP The approach I used was to generate all permutations and then filter out duplicates
@Daynewr a is previous and b is current
Dayne Wright
@daynewright
Aug 03 2015 19:03
ok. Thanks
Oliver
@Dadsaster
Aug 03 2015 19:04
It will only unnest one level
BoyanP
@BoyanP
Aug 03 2015 19:04
@Dadsaster I'm trying to do it with just the math and I can't figure out the cases where there are two sets of characters that repeat like the one with "abfdefa" has 2640 permutations but i have no clue how to get it mathematically
Oliver
@Dadsaster
Aug 03 2015 19:06
@Daynewr in steps it would go [[0, 1], [2, 3], [4, 5]] -> [0,1,2,3], [4,5] -> [0,1,2,3,4,5]
Marie Pelletier
@Marie000
Aug 03 2015 19:06
thanks @Dadsaster
CamperBot
@camperbot
Aug 03 2015 19:06
marie000 sends karma to dadsaster :thumbsup: :sparkles: :sparkles:
Oliver
@Dadsaster
Aug 03 2015 19:07
@BoyanP - sorry I can't be of more help - I did this one a long time ago and it took several days for me
BoyanP
@BoyanP
Aug 03 2015 19:08
ok thanks anyway :)
Justin Scoggin
@jscogg
Aug 03 2015 19:08

Working on Where art thou... here's what I did:

function where(collection, source) {
  var arr = [];
  var sourcePropVals = [];
  var colPropVals = [];
  // What's in a name?
  for (i = 0; i < source.length; i++) {
    for (var sourceProp in source[i]) {
      sourcePropVals.push(source[i][sourceProp]);
    }
  }
  for (j = 0; j < collection.length; j++) {
    for (var colProp in collection) {
      colPropVals.push(collection[j][colProp]);
    }
    if (collection[j].hasOwnProperty(Object.keys(source)) && (sourcePropVals === colPropVals)) {
      arr.push(collection[j]);
    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

I know this is a mess, but I've got no other idea how to go about doing this.

Nic Galluzzo
@ngalluzzo
Aug 03 2015 19:08
a is whatever you return.. so the ‘accumulator’ not necessarily the previous value
Oliver
@Dadsaster
Aug 03 2015 19:10
@ngalluzzo - that's a better way to put it
Matthew Senko
@mpskierbg
Aug 03 2015 19:13
function destroyer(arr) {
    var newarry = [];
    for(var i = 1; i< arguments.length; i++){
      newarry.push(arguments[i]);
    }
    return arr.filter(function(item){
      if(newarry.indexOf(item) >=0) {
        return false;
      } else {
        return true;
      }
    });
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
what is the return arr.filter(function(item) syntactically saying?
Nic Galluzzo
@ngalluzzo
Aug 03 2015 19:14
return the filtered items in arr @mpskierbg
Oliver
@Dadsaster
Aug 03 2015 19:15
@mpskierbg it's keeping any item with a true return and removing the items with a false return in the arr array
Dayne Wright
@daynewright
Aug 03 2015 19:20
I can’t seem to get there with steam roller. I know my code is not even close, but I can’t seem to understand how to fix it:
function steamroller(arr) {
  // I'm a steamroller, baby
  var out = [];
            if(Array.isArray(arr)){
                var flattened = arr.reduce(function(a, b){
                    return a.concat(b);
            });
    out.push(flattened);
  }
}

steamroller([1, [2], [3, [[4]]]]);
Dayne Wright
@daynewright
Aug 03 2015 19:32
Anyone? :)
Nic Galluzzo
@ngalluzzo
Aug 03 2015 19:33
assign that if to a function and use it to recursively check each item @Daynewr
Liz Rezes
@queenlizo
Aug 03 2015 19:35

Hey, all. My code in Bonfire: Truncate a string seems to be working, but I get that it's not passing this test:

expect(truncate('A-tisket a-tasket A green and yellow basket', 11)).to.eqls('A-tisket...');expected 'A-tisket a-' to deeply equal 'A-tisket...'

function truncate(str, num) {
  // Clear out that junk in your trunk
  if (str.length >= num) {
    return str.slice(0,num);
  }
  return str;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);

Any ideas? Thanks!

CamperBot
@camperbot
Aug 03 2015 19:35
type bonfire name
to get some info on that bonfire here
Liz Rezes
@queenlizo
Aug 03 2015 19:35
This message was deleted
Sean Rodman
@srodman7689
Aug 03 2015 19:35
@Daynewr I used toString() on steamroller
checkout how toString() works with arrays
Liz Rezes
@queenlizo
Aug 03 2015 19:36
bonfire Truncate a string
CamperBot
@camperbot
Aug 03 2015 19:36

:fire:Bonfire: Truncate a string :link:

function truncate(str, num) {
  // Clear out that junk in your trunk
  return str;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a '...' ending.

for more info: bf details bf links bf script bf wiki bf spoiler

Sean Rodman
@srodman7689
Aug 03 2015 19:37
@queenlizo You need to add three dots to the end of the string like this “…” and the string must still stop at the length.
Liz Rezes
@queenlizo
Aug 03 2015 19:37
@srodman7689 ah. Ok. Thanks! I'll try that.
Sean Rodman
@srodman7689
Aug 03 2015 19:39
Your welcome.
BoyanP
@BoyanP
Aug 03 2015 19:43
Bonfire No repeats please
CamperBot
@camperbot
Aug 03 2015 19:43
can't find a bonfire called no repeats please
Liz Rezes
@queenlizo
Aug 03 2015 19:43
@srodman7689 which string do I add that to? I tried it all over the place, and it's not working
Ben McMahon
@benmcmahon100
Aug 03 2015 19:46
bonfire no repeats
CamperBot
@camperbot
Aug 03 2015 19:46
can't find a bonfire called no repeats
Ben McMahon
@benmcmahon100
Aug 03 2015 19:46
hmm
bonfire No repeats please
CamperBot
@camperbot
Aug 03 2015 19:46
can't find a bonfire called bonfire no repeats please
Ben McMahon
@benmcmahon100
Aug 03 2015 19:46
bonfire No repeats please
CamperBot
@camperbot
Aug 03 2015 19:46
can't find a bonfire called no repeats please
dc
@dcsan
Aug 03 2015 19:47
bonfire repe
CamperBot
@camperbot
Aug 03 2015 19:47

:fire:Bonfire: Repeat a string repeat a string :link:

function repeat(str, num) {
  // repeat after me
  return str;
}

repeat('abc', 3);

Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.

for more info: bf details bf links bf script bf wiki bf spoiler

Afroz (zorfa)
@zorfa
Aug 03 2015 19:48
hi everyone!
Is anyone working on no repeats please bonfire? I have found the solution for it but the tests do not pass despite getting the right output
matejhegedus
@matejhegedus
Aug 03 2015 19:49
I've done it a couple hours ago.
Jelani Thompson
@JelaniThompson
Aug 03 2015 19:49
bf details
CamperBot
@camperbot
Aug 03 2015 19:49

:fire:Bonfire: Repeat a string repeat a string :link:

function repeat(str, num) {
  // repeat after me
  return str;
}

repeat('abc', 3);

Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

Global String Object


  • bonfire info for more info
  • bonfire links
  • bonfire script for the script
  • bonfire spoiler for some clues on how to solve it
  • bonfire wiki for related info from the wiki
Jelani Thompson
@JelaniThompson
Aug 03 2015 19:49
bonfire Chunky Monkey
CamperBot
@camperbot
Aug 03 2015 19:49

:fire:Bonfire: Chunky Monkey :link:

function chunk(arr, size) {
  // Break it up.
  return arr;
}

chunk(['a', 'b', 'c', 'd'], 2);

Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.

for more info: bf details bf links bf script bf wiki bf spoiler

Jelani Thompson
@JelaniThompson
Aug 03 2015 19:50
Hey guys! I'm doing this Bonfire right here and I'm kinda stuck
Here's the code I have so far, but I'm not really sure where to go from here
function chunk(arr, size) {
  var array = [];

  for (var i = 0; i < size; i++) {
    array.push(arr);
    if (i >= size) {

    }
  }

  return arr;
}

chunk(['a', 'b', 'c', 'd'], 2);
It wants me to return them as a multidimensional array, but I'm not really sure how to do that
I've been experimenting with push however
Afroz (zorfa)
@zorfa
Aug 03 2015 19:51
can someone tell me what tool to use to copy and paste code snippets on the chat here?
Grace
@dogbot101
Aug 03 2015 19:52
 Three tick marks like `, ``` (shift+enter for line break)
copy paste code, (shift+enter for line break) And three more tick marks
```
Jelani Thompson
@JelaniThompson
Aug 03 2015 19:52
^
Afroz (zorfa)
@zorfa
Aug 03 2015 19:53
thanks @dogbot101
CamperBot
@camperbot
Aug 03 2015 19:53
zorfa sends karma to dogbot101 :thumbsup: :sparkles: :sparkles:
Jelani Thompson
@JelaniThompson
Aug 03 2015 19:53
This camperbot is pretty cool
Moisés Man
@moigithub
Aug 03 2015 19:54
find array
CamperBot
@camperbot
Aug 03 2015 19:54
find array
nothing found
Afroz (zorfa)
@zorfa
Aug 03 2015 19:55
Test message
Moisés Man
@moigithub
Aug 03 2015 19:56
@JelaniThompson
var arr =[]
arr.push(1); <-- this will result in [1]
arr.push( [2] ); <-- this will result in [1, [2]] <-- 2d array
keagan goetsch
@misterrorypond
Aug 03 2015 19:56
could anyone possibly tell me why my buttons are so out of line? I believe it's the facebook button's problem
http://codepen.io/misterrorypond/pen/LVMqym
Rodrigo Bellusci
@rodrigomb81
Aug 03 2015 19:56
hey @JelaniThompson i think i can help you
Jelani Thompson
@JelaniThompson
Aug 03 2015 19:56
Thanks! Care to help in DM's? @rodrigomb81
CamperBot
@camperbot
Aug 03 2015 19:56
jelanithompson sends karma to rodrigomb81 :thumbsup: :sparkles: :sparkles:
Rodrigo Bellusci
@rodrigomb81
Aug 03 2015 19:56
ok
M Used
@mildused
Aug 03 2015 19:56
karma
thanks /@all
Thanks @rodrigomb81
CamperBot
@camperbot
Aug 03 2015 19:57
mildused sends karma to rodrigomb81 :thumbsup: :sparkles: :sparkles:
Sean Rodman
@srodman7689
Aug 03 2015 19:57
@queenlizo you add that to the end of the string you are truncating. so it will be something like
function truncate(str, num) {
  // Clear out that junk in your trunk
  return str.substring(0, num-3) + “…";
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
M Used
@mildused
Aug 03 2015 19:57
Thanks /@all
Liz Rezes
@queenlizo
Aug 03 2015 19:57
@srodman7689 Ooooh. I see. Thanks!
Sean Rodman
@srodman7689
Aug 03 2015 19:58
Your welcome.
Caleb
@CalebC4
Aug 03 2015 20:00
hello
Jelani Thompson
@JelaniThompson
Aug 03 2015 20:00
Yo Caleb :)
Hey guys, this is my friend Caleb btw :D
Invited him here since he wants to learn JS
But yeah, feel free to get started on some of the challenges man
Afroz (zorfa)
@zorfa
Aug 03 2015 20:01
Hi @CalebC4!!! Welcome to FCC!
Caleb
@CalebC4
Aug 03 2015 20:01
Hello :smile: just getting set up at the moment
Afroz (zorfa)
@zorfa
Aug 03 2015 20:02
good luck @CalebC4!! :)
Matthew Senko
@mpskierbg
Aug 03 2015 20:03
function destroyer(arr) {
  var mustRemove = [];
  for (var i = 1; i < arguments.length; i++) {
    mustRemove.push(arguments[i]);
  }
  return arr.filter(function(item) {
    if (mustRemove.indexOf(item) >= 0) {
      return false;
    } else {
      return true;
    }
  });
}
what does the if (mustRemove.indexOf(item) >= 0) syntactically say?
Justin Scoggin
@jscogg
Aug 03 2015 20:05
@mpskierbg the >= 0part is basically saying that if item exists in the array, then do whatever
matejhegedus
@matejhegedus
Aug 03 2015 20:06
The function indexOf() returns -1 if the item is not found in the array mustRemove.
Justin Scoggin
@jscogg
Aug 03 2015 20:06
^
Matthew Senko
@mpskierbg
Aug 03 2015 20:09
@matejhegedus can you describe for me quickluy what indexOf is?
Afroz (zorfa)
@zorfa
Aug 03 2015 20:10
@mpskierbg indexOf returns the location of "item" in an array
if the "item" is not present in the array then indexOf function returns the value -1 @mpskierbg
Matthew Senko
@mpskierbg
Aug 03 2015 20:14
@matejhegedus @zorfa in the above code can i interchange 'item' with any string? or is item specific?
Afroz (zorfa)
@zorfa
Aug 03 2015 20:15
item does not refer to any specific data type
@mpskierbg item can be string or number
Ariel
@ArielLeslie
Aug 03 2015 20:16
@mpskierbg item is just a variable name. You wouldn't want to use string because it's a special word, but there is nothing requiring you to use item
Liz Rezes
@queenlizo
Aug 03 2015 20:17

Hi, all. Still getting this error message with this code.

expect(truncate('A-tisket a-tasket A green and yellow basket', 11)).to.eqls('A-tisket...');expected 'A-tisket a-...' to deeply equal 'A-tisket...'

function truncate(str, num) {
  // Clear out that junk in your trunk
  if (str.length > num) {
    return str.slice(0,num) + "...";
  }
  return str;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);

However, when I change this line: if (str.length > num) to if (str.length > =num), it still doesn't work with that test. Any ideas?

that should be if (str.length > = num)
And when I change it to str.length >=== num, it says that there's an unexpected token =
That should be 2 ==
Afroz (zorfa)
@zorfa
Aug 03 2015 20:19
@queenlizo there shouldn't be 2 ==
Liz Rezes
@queenlizo
Aug 03 2015 20:19
Yea. Meant to write that
matejhegedus
@matejhegedus
Aug 03 2015 20:19
@queenlizo If the num is 11, you'll only want to show 8 letters of the original string + "..."
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 20:19
@queenlizo If I remember the bonfire correctly you have to count the three points in the number of characters
Liz Rezes
@queenlizo
Aug 03 2015 20:20
@vincepandolfo Ah. ok.
Clayton
@cjg040103
Aug 03 2015 20:20
what's wrong here?
This message was deleted
This message was deleted
$(document).ready(function() {
    $('div').click(function() {
        $(this).fadeOut('fast');
    });
});
$('div').hover(function(){
  $('div').addClass('red');
});
Ariel
@ArielLeslie
Aug 03 2015 20:21
@cjg040103 What errors are you having?
Clayton
@cjg040103
Aug 03 2015 20:22
here's the link 2 the codecademy challenge... https://www.codecademy.com/courses/web-beginner-en-JwhI1/0/4#
Reggie
@Reggie01
Aug 03 2015 20:22
@cjg040103 is it not adding the class
Clayton
@cjg040103
Aug 03 2015 20:22
@Reggie01 what shood i do?
why not?
Feners4
@Feners4
Aug 03 2015 20:23
any help with my my data is not displaying correctly?! http://codepen.io/Feners4/pen/EjONEe
Clayton
@cjg040103
Aug 03 2015 20:23
hold on... i hav an idea
Terrell Vest
@MirPresT
Aug 03 2015 20:24
@cjg040103 you have your code outside of the document . ready function ... just move it up one line
should look like this ... You had it right but sometimes formatting it can help you see things a bit better @cjg040103
$(document).ready(function() {
    $('div').click(function() {
        $(this).fadeOut('fast');
    });

    $('div').hover(function(){
        $('div').addClass('red');
    });
});
Clayton
@cjg040103
Aug 03 2015 20:25
@MirPresT ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhh...
Terrell Vest
@MirPresT
Aug 03 2015 20:25
@cjg040103 your welcome haha
Clayton
@cjg040103
Aug 03 2015 20:26
:satisfied:
me feels stoopid.
Terrell Vest
@MirPresT
Aug 03 2015 20:26
happens to the best of us -
Clayton
@cjg040103
Aug 03 2015 20:27
i hear THAT!
:+1: :smile:
@MirPresT thx
Terrell Vest
@MirPresT
Aug 03 2015 20:30
No problem -
David Taylor
@cornjacket
Aug 03 2015 20:31
hey everyone
matejhegedus
@matejhegedus
Aug 03 2015 20:32
hey @cornjacket
Steve
@sscastor
Aug 03 2015 20:32
in "FizzBuzz" what have I missed that the 2nd part of this statement isn't being read?else if (i % 3 == 0 && i % 5 == 0){
console.log("FizzBuzz");
David Taylor
@cornjacket
Aug 03 2015 20:34
hey @matejhegedus
matejhegedus
@matejhegedus
Aug 03 2015 20:34
@sscastor which part isn't being read?
Steve
@sscastor
Aug 03 2015 20:35
it returns 15 as fizz, so it's reading the 3 argument but not the 5
Joe Roland
@JPRoland
Aug 03 2015 20:37
@sscastor instead of that being your else if, make it the initial if statement.
Steve
@sscastor
Aug 03 2015 20:37
@JPRoland so check for fizzbuzz 1st and then move down?
Joe Roland
@JPRoland
Aug 03 2015 20:37
Yep
Steve
@sscastor
Aug 03 2015 20:38
@JPRoland :-) ok explain why that worked? and thanks btw
the documentation listed fizzbuzz as the 3rd statement so that's the order I worked in.
matejhegedus
@matejhegedus
Aug 03 2015 20:42
@sscastor if the expression behind the first if is true then it will just skip the code in the else block
This message was deleted
Steve
@sscastor
Aug 03 2015 20:43
so it was never making it to the && statement...that makes perfect sense...2 hours well spent :-)
I should have logic'd that out before, makes for a duh..moment
Vitalii Danylov
@vitaliidanylov
Aug 03 2015 20:44
Hi everyone!
Could someone explain what's wrong with code...
function find(arr, func) {
  var num = 0;
  for(var i=0; i<arr.length; i++){
    if(arr[i].some(func)){
      num = arr[i]; break;
    }
  }
  return num;
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });
Joe Roland
@JPRoland
Aug 03 2015 20:45
There are a lot of those duh moments in programming.
rayner-villalba-coderoad-com
@rayner-villalba-coderoad-com
Aug 03 2015 20:48
Hello guys do you have an example how to edit .env file I couldn't start the app any idea ??
matejhegedus
@matejhegedus
Aug 03 2015 20:50
@vitaliidanylov I think you can use some() only with the whole array, not a specific element of the array.
Lightwaves
@Lightwaves
Aug 03 2015 20:51
@matejhegedus some function is similar to a
if(condition)
break;
So as soon as the condition evaluates true it stops looping
matejhegedus
@matejhegedus
Aug 03 2015 20:55
@Lightwaves Yeah, but I don't think it's used correctly in @vitaliidanylov 's code.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
Clayton
@cjg040103
Aug 03 2015 20:58
what's wrong w/ my syntax?
confirm("Ready?");
var age = prompt("What's your age");
if (age is less than 13);
{
    console.log('You can play, but I am not to be held responsible.')
};
else
{
    console.log('Play on!')
};
Vitalii Danylov
@vitaliidanylov
Aug 03 2015 20:58
@matejhegedus @Lightwaves
function find(arr, func) {
  var num = 0;
  var tmp = [];
  for(var i=0; i<arr.length; i++){
    tmp[0]=arr[i];
    if(tmp.some(func)){
      num = arr[i]; break;
    } else {
      num = undefined;
    }
  }
  return num;
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });
Clayton
@cjg040103
Aug 03 2015 20:59
brb 1 min
Teddi Jordan
@teddilu
Aug 03 2015 21:00
@cjg040103 - You need to use less than symbol, not write out “is less than"
Clayton
@cjg040103
Aug 03 2015 21:00
k im bak
@teddilu k
Vitalii Danylov
@vitaliidanylov
Aug 03 2015 21:00
@matejhegedus thnx for advice, now I see what is wrong, I put in function number not an array...so tha was a problem
Clayton
@cjg040103
Aug 03 2015 21:00
@teddilu nope...
Lightwaves
@Lightwaves
Aug 03 2015 21:01
I'm going to give you two seperate ways to go about doing this.
well in pseudocode
Teddi Jordan
@teddilu
Aug 03 2015 21:02
@cjg040103 - You also need semicolons after your console.log statements.
Lightwaves
@Lightwaves
Aug 03 2015 21:02
bleh can't do it here
Darrell Wong
@darrell1226
Aug 03 2015 21:02
Any advice on how to approach completing Zipline: Stylize Stories on Camper News? I looked at it and tried using my methods of building a simpler page but I clearly need something like Angular to build it. I loaded Angular and tried several commands but I haven't been successful yet. Should I watch a 4 hour tutorial before trying Angular again?
Clayton
@cjg040103
Aug 03 2015 21:02
@teddilu k
Lightwaves
@Lightwaves
Aug 03 2015 21:02
I'll be back in 30 minutes
Joe Roland
@JPRoland
Aug 03 2015 21:02
@cjg040103 you also have some semicolons where you shouldn't have semicolons.
Joris Labie
@labiej
Aug 03 2015 21:02
@darrell1226 why would you need angular?
I built it with just HTML5, CSS and jQuery a few days ago
Clayton
@cjg040103
Aug 03 2015 21:04
here's wat i hav now
confirm("Ready?");
var age = prompt("What's your age")
if (age <= 13);
{
    console.log('You can play, but I am not to be held responsible.');
};
else
{
    console.log('Play on!');
}
Teddi Jordan
@teddilu
Aug 03 2015 21:08
@cjg040103 - You still have some trouble with your semicolons. Look at this guide: https://www.codecademy.com/blog/78-your-guide-to-semicolons-in-javascript
Darrell Wong
@darrell1226
Aug 03 2015 21:08
@labiej I guess I got stuck on writing code that could handle 100 news stories. I thought I would have to use something like ng-repeat in Angular to build a framework to handle 100 stories.
Clayton
@cjg040103
Aug 03 2015 21:08
@teddilu thx
:smile:
Teddi Jordan
@teddilu
Aug 03 2015 21:09
@cjg040103 You’re welcome.
Kristin Anthony
@anthkris
Aug 03 2015 21:09
Could use some help with the Exact Change bonfire. I think it needs a recursive solution but I don't know how to get started
function drawer(price, cash, cid) {
  var change;
  // find change owed
  var changeOwed = cash - price;
  // find total cash in drawer
  var totalCash = [];
  totalCash = totalCash.concat.apply(totalCash, cid); //projects and flattens cid array
  totalCash = totalCash.filter(function(cashItem){
    if (typeof cashItem === "number"){
      return cashItem;
    }
  }).reduce(function(prev, next){
    return prev + next;
  });

  //if changeOwed > totalCash
    //return the string "Insufficient Funds"
   if (totalCash < changeOwed){
     change = "Insufficient Funds";
    } else if (changeOwed === totalCash){
      //else if changeOwed === totalCash
    //return the string "Closed"
      change = "Closed";
    } else {
      //Else return array of change denominations, starting from the highest possible denom to the lowest
      //implies recursion
      change = [];
      if (changeOwed % 100 === 0){

      }
    }



  return change;

}

// Example cash-in-drawer array:
// [['PENNY', 1.01],
// ['NICKEL', 2.05],
// ['DIME', 3.10],
// ['QUARTER', 4.25],
// ['ONE', 90.00],
// ['FIVE', 55.00],
// ['TEN', 20.00],
// ['TWENTY', 60.00],
// ['ONE HUNDRED', 100.00]]

drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);
Joris Labie
@labiej
Aug 03 2015 21:11
@darrell1226 if you know how to use angular by all means use it. It is however perfectly possible using jquery since the stories arrive as a single array
Darrell Wong
@darrell1226
Aug 03 2015 21:11

@labiej Here's my code that I have trouble expanding. I don't know how to loop through each news article on the HTML side. Maybe a forEach loop would work on the JS side but can I save myself from typing ```

<div class="col-xs-3 1" ng-repeat="article in articles">
<a href= ><img src= /><h4></h4></a>
<button><a href={{discuss}}>Discuss</a></button>
</div>
```
100 times?

Joris Labie
@labiej
Aug 03 2015 21:12
I just created/appended the elements to a wrapper-div
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:12
@anthkris still working on that one but pretty sure that last bit is also done with a reduce
Darrell Wong
@darrell1226
Aug 03 2015 21:13
<div class="row">
        <div class="col-xs-3 1">
          <a href= ><img src= /><h4></h4></a>
          <button><a href=>Discuss</a></button>
        </div>
      </div>
Joris Labie
@labiej
Aug 03 2015 21:13
So my HTML looks like <div id="wrapper"></div> and in jQuery I use $('#wrapper').append( storyBlock
Kristin Anthony
@anthkris
Aug 03 2015 21:13
@ngalluzzo Reduce, huh? I'll give that a think.
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:14
@anthkris I think.. I gave up on it yesterday gonna revisit once I’m done with work
We need to be able to tell how much a ‘PENNY’ is actually worth.. so I added a ‘value’ to each array
Joris Labie
@labiej
Aug 03 2015 21:15
storyBlock += "<img src='" + imgURL + "'>";
storyBlock += "<h3>" + title + "</h3>";
...
Kristin Anthony
@anthkris
Aug 03 2015 21:15
@ngalluzzo Definitely would have been easier if it had been an array of objects
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:15
yeah I transformed it into an array of objects
Joris Labie
@labiej
Aug 03 2015 21:15
It still is 100 lines of code but that's mainly html @darrell1226
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:15
don’t see how to do it otherwise hah
Kristin Anthony
@anthkris
Aug 03 2015 21:16
@ngalluzzo I thought about that, but I figured that gave me an array of arrays for a reason
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:16
to blow your brain up
Kristin Anthony
@anthkris
Aug 03 2015 21:16
besides which you have to return an array in the result
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:16
the only suggestion points to the Global Object MDN link
yeah you do
Kristin Anthony
@anthkris
Aug 03 2015 21:17
My brain has definitely 'sploded
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:17
you’re also gonna run into rounding issues… right now you’re returning whole numbers instead of fixed to 2 decimals
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:21
@labiej why do you need all that code?
Joris Labie
@labiej
Aug 03 2015 21:22
because I used jQuery?
no idea how to shorten it and avoid things like > join 1 commenters
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:22
@labiej I used jQuery too and I wrote ~30 lines of JS code, half of them are html
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:23
to each their own :)
Joris Labie
@labiej
Aug 03 2015 21:23
also I used $.ajax which gives some overhead :-)
Oh I had to wait until all images were loaded to ensure my layout wouldn't get broken
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:25
but I used Bootstrap's list-group for the layout. That simplifies everything if I got what your codes do
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:26
LOL @vincepandolfo
so you used thousands of JS lines then
Joris Labie
@labiej
Aug 03 2015 21:26
I don't understand the bootstrap stuff. And to be honest I don't like it one bit
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:26
oh sorry I thought you said angular HAH
that woulda been great
bootstrap offers such a great foundation for learning HTML basics.
Joris Labie
@labiej
Aug 03 2015 21:27
I find it reminiscent of using tables to build layouts
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:27
@ngalluzzo I don't know Angular yet. Hell, I didn't even know JS last week lol
Darrell Wong
@darrell1226
Aug 03 2015 21:27
@vincepandolfo Do you want to share what you did?
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:27
nothing wrong with using tables to build layouts!
still do that here and there
Joris Labie
@labiej
Aug 03 2015 21:28
it's hacky
and bad form semantically
but that's my inner autist
But my layout is completely different
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:29
@vincepandolfo a lot of his code is to calculate margins and stuff to dynamically place a new div
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:29
@ngalluzzo yeah I saw that after writing
Liz Rezes
@queenlizo
Aug 03 2015 21:30
I'm back again. lol. I just can't get this code to work.
function truncate(str, num) {
  // Clear out that junk in your trunk
  var myString = str+"...";
  if (myString.length >= num) {
    return myString.slice(0,num);
  }
  return myString;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:31
I don't like that kind of style. Looks untidy to me
@queenlizo You're still not counting the three points
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:31
‘…’ need to be accounted BEFORE you slice it
Liz Rezes
@queenlizo
Aug 03 2015 21:32
@vincepandolfo Right. That's why I created the variable myString
Sean Rodman
@srodman7689
Aug 03 2015 21:32
@queenlizo you have to add the three “…” after you sslice it.
Liz Rezes
@queenlizo
Aug 03 2015 21:32
Which obviously isn't working.
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:32
@queenlizo Yes, but you're removing them when you slice the string
Joris Labie
@labiej
Aug 03 2015 21:32
You need to remove the extra characters before adding dots
Sean Rodman
@srodman7689
Aug 03 2015 21:33
@queenlizo
function truncate(str, num) {
  // Clear out that junk in your trunk
  var myString = "";
  if (myString.length <= num) {
    return myString.slice(0,num);
  }
  return myString;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
Nic Galluzzo
@ngalluzzo
Aug 03 2015 21:33
also @queenlizo your second return MyString is being called regardless of the if
function truncate(str, num) {
  // Clear out that junk in your trunk
  var myString = str+"...";
  if (myString.length >= num) {
    return myString.slice(0,num);
  }
else {
  return myString;
}
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
Vincenzo Pandolfo
@vincepandolfo
Aug 03 2015 21:34
@ngalluzzo The second return is not called if the return in the if is executed
Liz Rezes
@queenlizo
Aug 03 2015 21:34