These are chat archives for FreeCodeCamp/Help

6th
Mar 2015
Cristián Berríos
@crisberrios
Mar 06 2015 00:02
if (!(k in o2))
I've never seen if...in before
Suzanne Atkinson
@AdventureBear
Mar 06 2015 00:02
@crisberrios nice job!
Cristián Berríos
@crisberrios
Mar 06 2015 00:02
am I missing something?
@AdventureBear I'm still working at it
do you see the obstacle moving?
Suzanne Atkinson
@AdventureBear
Mar 06 2015 00:03
yes one time a cross
when I hit hte space bar the whole screen moves so it's all ground
Cristián Berríos
@crisberrios
Mar 06 2015 00:05
still have to add features, but it's moving :D
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 00:05
@crisberrios hm...well I found the construction in stack overflow...maybe it's not kosher but it seems to work in terms of solution but not getting past the bonfire tests. maybe the construction isn't acceptable for other reasons.
Cristián Berríos
@crisberrios
Mar 06 2015 00:07
yeah, it's valid
hmm seems logic
not very explicative but logic
let me check why it's failing
Suzanne Atkinson
@AdventureBear
Mar 06 2015 00:10
it's fun. what's your plan?
Cristián Berríos
@crisberrios
Mar 06 2015 00:11
expected [ '4' ] to deeply equal [ 4 ]
the error is because keys are being stored as strings
and they can be numbers
@AdventureBear just check for collision and add some scoring, maybe a background
Suzanne Atkinson
@AdventureBear
Mar 06 2015 00:12
how about diving birds?
Cristián Berríos
@crisberrios
Mar 06 2015 00:12
It's only an afternoon exercise
don't expect too much
:P
Suzanne Atkinson
@AdventureBear
Mar 06 2015 00:13
:)
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 00:13
thanks for checking, @crisberrios ....any suggestions?
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 00:53
@crisberrios I just added a check for number and changed before the push...but I'm thinking my solution isn't probably as good as others. I heard that we might get to see other solutions at some point, I'm in favor! here's what I did ```
This message was deleted
oops, realized probably aren't supposed to post solutions...well anyway, my main idea was that when it's possible I'd love to see better solutions! That's it...thanks.
Cristián Berríos
@crisberrios
Mar 06 2015 01:08
try with indexOf and lastIndexOf
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 01:10
okay didn't know of those, look really helpful for next bonfire...the alphabet matching!
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:18
OK, i'm doing destroyer bonfire now
playing with just getting the data
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
destroyer(arr) ... return arr; returns only the first subelement, not the entire thing
Cristián Berríos
@crisberrios
Mar 06 2015 01:20
you might want to read about the arguments object
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:20
function destroyer(arr) {

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
ahh. OK, I can do that. Anyway ^^^ returns 1,2,3,1,2,3
actually [1,2,3,1,2,3]
Cristián Berríos
@crisberrios
Mar 06 2015 01:21
hint: 2 and 3 are located at arguments[1] and arguments[2], but arguments it's not an array.
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:21
hmm.
OK, that helps for now
is the bonfire written so that arguments[0] coudl be any length array , and there may be 1 or more additional arguments?
in otherwords, we don't know? I was trying to use a shift function to get the first array, leaving the remainder.
nevermind. it's only property is .length
Cristián Berríos
@crisberrios
Mar 06 2015 01:24
;)
I'll also tell you a super ninja trick
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:24
oh good! please do../
is argument[0] an array though? (in this example)
@terakilobyte is there a backdoor way right now to see our solutions to previous bonfires?
Cristián Berríos
@crisberrios
Mar 06 2015 01:26
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:27
cool!
but isn't that what this is warning abotu?
You should not slice on arguments because it prevents optimizations in JavaScript engines (V8 for example). Instead, try constructing a new array by iterating through the arguments object.
even still I'm far from solving this one, lol. that's a good start.
Cristián Berríos
@crisberrios
Mar 06 2015 01:30
I've read the slice thing in many books.
lol.
It's even in the examples below the warning
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:34
OK, making some progress
you think filter would be a good next step?
or splice?
Cristián Berríos
@crisberrios
Mar 06 2015 01:38
I think filter, since you want to filter :P
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:38
@crisberrios do you havea coding blog?
lol
OK...really been trying to use filter, now 's the time!
Cristián Berríos
@crisberrios
Mar 06 2015 01:39
not yet
I want to turn my current site into a coding/portfolio site eventually
but I'm just building my portfolio
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:41
I think you could create a nice series for people to learn from...like your daily jquery challenge stuff.
Cristián Berríos
@crisberrios
Mar 06 2015 01:43
Maybe, but I want to be a good coder first
I wouldn't like to be a one-eyed leading the blind
or worse yet
a blind leading the blind
I still have to interiorize and learn many good practices and design patterns
Suzanne Atkinson
@AdventureBear
Mar 06 2015 01:47
I can see that, but the other side of that is you could share your stories of how you went abou tlearning. For example...I kept a medical blog from my internship on. I was clueless as a doctor but it helped people see what it was like being an intern, then a 2nd year, then a fresh attending, etc. But I totally get what you'r esaying.
Cristián Berríos
@crisberrios
Mar 06 2015 01:52
nice blog!
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:09
thanks! you mean that particular entry? or the whole thing? lol. it's a mish mash of stuff and the template needs work
Cristián Berríos
@crisberrios
Mar 06 2015 02:11
the whole thing, it seems that you blog on many topics
I've never been constant with my blogs
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:12
it used to be great therapy for me
and a way to keep in touch with my family while I was a resident
I could just blog stuff, and my dad would read the entries, then print them out and mail them to my grandmother.
one of them was actually published in one of the priamry medical journals, the Annals of Emergency Medicine as a prose piece.
that's why I think you could easily blog stuff now even though you don't feel like an expert. I think as long as it's clear where you are in your developemnet, it will be useful for that slice of the audience
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:43
@crisberrios or @chrisdziewa you guys still up?
I've got 98% of a solutoin for destroyer. Missing the magic though
Cristián Berríos
@crisberrios
Mar 06 2015 02:44
I'm still here
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 02:45
@AdventureBear seriously, great blog!!!
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:45
OK, can I show you what I have? I'd ask to pair but my boyfriend is sleeping on the couach right now, lol
@MetaCoderHirschl
thank you!
function destroyer(arr) {

  var newArgs = Array.prototype.slice.call(arguments);
  first = newArgs.shift();

  destroyed = first.filter(function(value){
   if (//value not in newArgs) {

        return value;
      }
  });

  return destroyed;

}
so...i get the first array out of (arr) using arguments, and what's left after the shift are the values to test against
I want to filter "first" so that's the array I use the filter method on, use a n anonymous callback and....
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:50
I'm stuck. newArgs as the other times I want to remove
Cristián Berríos
@crisberrios
Mar 06 2015 02:51
remember that filter looks for true and false in the return value
and check indexOf method of Array
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:53
do I need to pass any arguments in the cb function?
Cristián Berríos
@crisberrios
Mar 06 2015 02:55
what callback?
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:56
in first.filter(function()) above, isn't the function a callback?
so I want to return the value of the element being iterated over from first... IF it is NOT found in the remaining arguments.
mostly thinking out loud here.
Cristián Berríos
@crisberrios
Mar 06 2015 02:57
no, it's not a callback
Suzanne Atkinson
@AdventureBear
Mar 06 2015 02:57
dang I thought I had it figured out.
now I htink everything is a callback!
Cristián Berríos
@crisberrios
Mar 06 2015 02:58
filter will push the value into the destination array if the return value is true
or filter it if the return value is false
the function does need at least a parameter
which is the item being filtered
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:02
why is this so hard for me?
it's not only like learning a new language but there are new grammar rules
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 03:03
@AdventureBear I've thought about this a lot, imho --- it is hard because we have to learn how JS thinks, what tools they have to solve the problem AND understand the bonfire. I swear I spent 2 hrs solving a bonfire with answer that worked...but not exactly what was asked for...then when I understood it, it was easier!!!
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:04
so with array.indexOf(searchValue) syntax, is the searchValue only a character?
Cristián Berríos
@crisberrios
Mar 06 2015 03:04
it can be any type of value
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:04
because in the bonfire, there is more than one value to fliter
so can I pass the array?
Cristián Berríos
@crisberrios
Mar 06 2015 03:04
you are already passing an array, to filter
then in filter, you define a function
to that function, you pass only a character
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:05
I know, but I have a 2nd array with the other 2 values
Cristián Berríos
@crisberrios
Mar 06 2015 03:05
or an array entry
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:05
right that's my question. Hmm.
Cristián Berríos
@crisberrios
Mar 06 2015 03:05
then use indexOf in the array
not in the original array
arrA.indexof(b) or arrB.indexOf(a)
that is the question
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:07
using your splice trick, followed by my shift trick, I now have 2 arrays.
but theIndex of I can only pass a character, so I'll need to access the altered array from the shift method. Does that make sense?
Cristián Berríos
@crisberrios
Mar 06 2015 03:09
I think it does
Carlos Toro Vera
@carmelo12341
Mar 06 2015 03:11
I need help with a bonfire
Cristián Berríos
@crisberrios
Mar 06 2015 03:11
but more than where to apply the indexOf method, think of how is indexOf method useful to filter
what happens when the item is found, or when it's not
which one carmelo?
Carlos Toro Vera
@carmelo12341
Mar 06 2015 03:12
the chunky monkey one
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:12
OK @crisberrios here's my latest, I forced in just 1 argument to filter, but it doesn't return the expected result (my expected)
function destroyer(arr) {

  var newArgs = Array.prototype.slice.call(arguments);
  first = newArgs.shift();

  var filtered = first.filter(function(value){
   if (first.indexOf(newArgs[0]) != -1) {
      return value; 
      }

  });

  return filtered;

}
Cristián Berríos
@crisberrios
Mar 06 2015 03:13
you somehow managed to make it worse :P
but don't fall into despair
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:15
WHAT???
IT"S BEAUTIFUL!
SO. ELEGANT!
but it gives the wrong answer. At least it runs. :)
function destroyer(arr) {

  var newArgs = Array.prototype.slice.call(arguments);
  first = newArgs.shift();

  var filtered = first.filter(function(value){
   if (first.indexOf(newArgs[0]) === -1) {
      return value; 
      }

  });

  return newArgs[0];

}
oh I returned newArgs[0] to check and make sure it's what I expectd
Chris Dziewa
@chrisdziewa
Mar 06 2015 03:17
@AdventureBear what is the url for that one
Chris Dziewa
@chrisdziewa
Mar 06 2015 03:18
ah ok thanks
Cristián Berríos
@crisberrios
Mar 06 2015 03:19
the function within filter will apply to each entry of "first", one at a time
so, if "first" has [0,1,2]
value will be 1, then 2, then 3
for each iteration
and at the end of the function
you want to return either true or false
if you return true
value will be pushed to the new array
if it's false, it won't
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:22
so when i use that if statement inside the filter call it's not doing anytying, since I'm trying to use the array ('first') again?
Cristián Berríos
@crisberrios
Mar 06 2015 03:23
you can eventually use the array again
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:23
OMG it worked!
Cristián Berríos
@crisberrios
Mar 06 2015 03:23
but the thing is, you aren't using value
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:25
right. I swapped the indexOf statement by using the array containing the 'destroyer' elements and passing the value there.
@carmelo12341 's turn for help!
Thanks. 2 bonfires tonight. Progress. :)
Cristián Berríos
@crisberrios
Mar 06 2015 03:26
change value with "true"
don't return value
because, what filter is doing
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:26
@MetaCoderHirschl how are you doing?
Cristián Berríos
@crisberrios
Mar 06 2015 03:26
is analyzing the truth value of value
but if you pass a 0
0 is "false"
and the function will fail
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:27
what do I return?
or I don't have to return with filter?
Cristián Berríos
@crisberrios
Mar 06 2015 03:27
true
Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:27
oh
Carlos Toro Vera
@carmelo12341
Mar 06 2015 03:27
I will keep trying to do it by myself :), It is already too late and I don't have much time

IHateSchool

Suzanne Atkinson
@AdventureBear
Mar 06 2015 03:28
there it is. can you still see my replit?
@crisberrios sounds like you may have learned that through experience. (about passing 0)
Cristián Berríos
@crisberrios
Mar 06 2015 03:31
a mix of experience and helping people with bonfires :)
Russ Otto
@rustyautoparts
Mar 06 2015 03:34
i just finished the "Confirm the Ending" bonfire, but I'm wondering if there's a better way to solve it than what i came up with.
Cristián Berríos
@crisberrios
Mar 06 2015 03:41
function end(str, target) {
   return str.substring(0,str.length-target.length)+target === str;
  }
never seen that one before, I came up with this
function end(str, target) {
   return str.substring(str.length-target.length,str.length) === target;
  }
or this
Vince
@Vince33
Mar 06 2015 05:10
Hey guys, so wondering what is the advantage to memoisation when writing recursive functions for example for factorial or fibonacci?
function memoizer(memo, formula) {
        var recur = function (n) {
            var result = memo[n];
            if (typeof result !== 'number') {
                result = formula(recur, n);
                memo[n] = result;
            }
            return result;
        };
        return recur;
    };

    var factorial = memoizer([1, 1], function (recur, n){
        return n * recur(n - 1);
    });

    var fibonacci = memoizer([0,1], function (recur, n){
        return recur(n - 1) + recur(n - 2);
    });
Germaine Pannell
@germainep
Mar 06 2015 05:17
its like a memory bank so the function doesn’t have to process everything all at once
or thats how i understand it
Vince
@Vince33
Mar 06 2015 05:19
I want to understand it better I know it acts as like a cache and somehow makes something like fibonacci a linear process , but it still blows the stack pretty quickly if n is too high of a value
the memory is releaving some of the up and down of the recursion
?
Tate Thurston
@tatethurston
Mar 06 2015 06:39
I'm having some trouble with the bonfire challenge symmetric difference -- has anyone completed this challenge?
Specifically, I don't understand the expected answers. i.e why is the result of sym([1, 1]),1) supposed to be 1?
Carlos Cesar Llanos
@ccllanos
Mar 06 2015 12:37
@tatethurston there is only one set in sym([1, 1]),1), namely [1, 1]. You're searching for the element "1" and it IS present in the first set, and because this set is unique your function should return 1 because it's present in the first set, but not in a second, hypothetical (in this case) set.
you should return all elements that are present in at least one set, if they are, but not if they can be found in two or more sets
Ammar Ali Shah
@AmmarAliShah
Mar 06 2015 12:54
var pizza = 'pizza is alright';
pizza = pizza.replace('alright', 'wonderful');
this code is correct, right?
Kamal Sharif
@ksharifbd
Mar 06 2015 12:56
right
Ammar Ali Shah
@AmmarAliShah
Mar 06 2015 12:56
then why does javascripting not accept it!!!
Kamal Sharif
@ksharifbd
Mar 06 2015 12:59
Which environment you are running the code?
Ammar Ali Shah
@AmmarAliShah
Mar 06 2015 13:00
@ksharifbd verifying it on the terminal(Ubuntu 14.10) using javascripting
I'll just read the instructions again
Kamal Sharif
@ksharifbd
Mar 06 2015 13:01
oh! windows guy here. :P
Danny Fritz
@dannyfritz
Mar 06 2015 15:55
@AmmarAliShah which js environment is "javascripting"
Cristián Berríos
@crisberrios
Mar 06 2015 15:56
:P
at least it does exist
Danny Fritz
@dannyfritz
Mar 06 2015 16:06
ah, i guess node then. :P
Cristián Berríos
@crisberrios
Mar 06 2015 16:07
I forgot to send you my no repeats improvement
Danny Fritz
@dannyfritz
Mar 06 2015 16:08
yeah!
Ammar Ali Shah
@AmmarAliShah
Mar 06 2015 16:13
@dannyfritz it's not an environment
It's the name of the course at nodeschool.io
It works in the terminal
Cristián Berríos
@crisberrios
Mar 06 2015 16:16
yeah, I've already read the docs
seems a good tool to learn some basics
Ammar Ali Shah
@AmmarAliShah
Mar 06 2015 16:17
@crisberrios yeah only the basics
I was going to actually use the node one but I gave this a shot
Jon Lucas
@jonslucas
Mar 06 2015 18:23
@crisberrios Would you mind sending my your supa-fast no-repeats solution? I'd like to compare it to mine
Cristián Berríos
@crisberrios
Mar 06 2015 18:51
it's not "super fast" bat faster than simple brute forcing :P
jonnydc
@jonnydc
Mar 06 2015 21:31

cant figure out this challenge Check for Palindromes
Difficulty:
Return true if the given string is a palindrome. Otherwise, return false.

A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.

You'll need to remove punctuation and turn everything lower case in order to check for palindromes.

We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.

Less information
Run code (ctrl + enter)

false

assert.deepEqual(palindrome("nope"), false);AssertionError:expected true to deeply equal false
assert.deepEqual(palindrome("not a palindrome"), false);AssertionError:expected true to deeply equal false
expect(palindrome("eye")).to.be.a("boolean");
assert.deepEqual(palindrome("eye"), true);
assert.deepEqual(palindrome("race car"), true);
assert.deepEqual(palindrome("A man, a plan, a canal. Panama"), true);
assert.deepEqual(palindrome("never odd or even"), true);

function palindrome(str) {

// Good luck!

if(str !== palindrome){

return true;

}

else(paulindrome = emordniluap){

return false;

}

}

palindrome(palindrome);

cerissa
@cerissa
Mar 06 2015 21:45
can someone tell me whats wrong with this code? im doing treehouse and its not accepting it
var answer = prompt("what is the best programming language?");
if( answer === 'javascript'){
  alert("You are correct");
  }
Darryl Dixon - Piece Digital
@piecedigital
Mar 06 2015 21:46
nothing, unless their answer has a cap
it's still case sensitive.
also, there is not else for if they get it wrong.
cerissa
@cerissa
Mar 06 2015 21:47
it didnt look wrong to me either, let me try getting out of it and trying again
they dont want the else yet
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 21:53
@cerissa this code works just fine in jsfiddle...maybe a glitch in treehouse?
Danny Fritz
@dannyfritz
Mar 06 2015 21:55
does it matter that it is looking for a lowercase "javascript"?
cerissa
@cerissa
Mar 06 2015 21:56
i had tried uppercase for Javascript but i forgot to also use an uppercase S so it wanted it like this JavaScript
stupid thing
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 21:56
definitely the case needs to be considered (change all to lower case for ease) but I thought the problem was the code wouldn't execute...and it did.
cerissa
@cerissa
Mar 06 2015 21:59
thats what i hate about these types of things, it just told it to recheck my work, and i knew it looked right. the S being capitalized was just crazy
Meta Hirschl
@MetaCoderHirschl
Mar 06 2015 22:00
@cerissa yeah, computers are sooo very literal. no imagination whatsoever.
cerissa
@cerissa
Mar 06 2015 22:01
when creating a course like that i think they need to make it so for answers like that capitalization doesnt matter