These are chat archives for FreeCodeCamp/Help

4th
Apr 2015
Tim
@TimRizzo
Apr 04 2015 04:04

Hey, all... I was working on 'finders keepers' bonfire and looking at some of the built in array methods like .some()

function find(arr, func) {
  var num = 0;
  return num;
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });

and I don't know the right words to search this... it feels like something I learned but can't see:
If I have a function(1) that takes another function(2) as an argument, how do I write the function(1) to pass in a variable to the other function(2) when it's called? What is the syntax?

aw, crap. you know all it took was typing it out. you just use the variable name the referenced function uses, don't you?
Cristián Berríos
@crisberrios
Apr 04 2015 04:10
hi @TimRizzo
that's right
seems that you already solved the problem
Tim
@TimRizzo
Apr 04 2015 04:26
@crisberrios Well, at least I've got the right tools now :-)
Tim Pinoy
@waeren
Apr 04 2015 14:36
My English is failing me on the smallest-common-multiple bonfire. I thought we had to calculate the least common multiple but if that's the case then the tests don't make much sense. Does anyone have a better explanation of the objective for it?
Sudeepto
@Sudeepto
Apr 04 2015 14:41
@waeren Even division is exact division with no remainder .
Tim Pinoy
@waeren
Apr 04 2015 14:46
but for input [5,1] shouldn't it just be 5 instead of 60?
Sudeepto
@Sudeepto
Apr 04 2015 14:48
Yeah. I have to think about it for a moment :)

@waeren I think we need to find the smallest number that gets divided evenly by all the numbers in the list .

So 1, 2, 3, 4, 5 all divide 60 and I think there is no number smaller than 60 that gets divided by all of them.

Tim Pinoy
@waeren
Apr 04 2015 14:55
That makes sense, thanks for the help!
Sudeepto
@Sudeepto
Apr 04 2015 14:58
@waeren No problem. But I think I should tell the guys who moderate these bonfires about this.
Tim Pinoy
@waeren
Apr 04 2015 15:01
Might've been just a brain fart on my end though. After your explanation I reread the challenge and facepalmed when I saw the word range in there twice.
Sudeepto
@Sudeepto
Apr 04 2015 15:03
@waeren English is not my native language. But still I think the bonfire asks us to find the smallest number that divides all the number in the range. So it asks us to find a number that will in the denominator of the fraction right ?? Or am I missing something here ?
Tim Pinoy
@waeren
Apr 04 2015 15:07
Mm true, maybe the following would be better:
Find the smallest number that gets evenly divided by all numbers in the provided range.
tbh I just used wolfram alpha and searched for smallest common multiple (1,5)
Math can be pretty confusing if it's in a different language
Sudeepto
@Sudeepto
Apr 04 2015 15:40

@waeren Yeah . I always scored less in Mathematics because most of the time the language felt alien to me. :worried:

I also calculated the lcm of 1, 2, 3, 4, 5 and the answer was 60 :smile: So we just have to calculate lowest common multiple of numbers given in the range and we are done. :+1:

Jonathan
@jonathantimm
Apr 04 2015 17:48
Hey ya'll, super basic jquery question for anyone. You can probably tell that my attempt to fadeout the last list item here is wrong, but I can't remember what i'm supposed to do to get it right:
Cristián Berríos
@crisberrios
Apr 04 2015 17:49
:question:
Jonathan
@jonathantimm
Apr 04 2015 17:49
$(document).ready(function() {
var $target = $("<li>").last;
$target.fadeOut('fast');
});
It's actually the last list item in the <ol>
Cristián Berríos
@crisberrios
Apr 04 2015 17:50
it should be 'li'
and i'm not 100% sure but I think it might be last() and not last
Jonathan
@jonathantimm
Apr 04 2015 17:51
ah
also thanks to getting rid of the <> i just realized that this works too:
Cristián Berríos
@crisberrios
Apr 04 2015 17:51
check jQuery docs
it's the best resource :)
Jonathan
@jonathantimm
Apr 04 2015 17:51
var $target = $("li:last-child");
jquery docs, ok
thank you!
Sudeepto
@Sudeepto
Apr 04 2015 18:13

@crisberrios Hey I have to ask you something. I was helping one fellow FCC member in solving a bonfire question Smallest common multiple.
But we both concluded that the problem statement is a bit confusing.

It asks us to find the smallest number that evenly divides all the numbers in the given range. But we found out that it should be the smallest number that gets evenly divided by each of the number in the range given. In the former case , the required number should be the denominator of the fraction, but in the latter case, it is the numerator. I hope I clearly mentioned my concern :smile:

I haven't solved the problem. But if I consider my assumption, then we just have to find the lowest common multiple of the range of numbers given.

Can you please look at it ??

Cristián Berríos
@crisberrios
Apr 04 2015 18:16
yes, I think your wording is right
the other case would be GCD
Sudeepto
@Sudeepto
Apr 04 2015 18:17
Yup :+1:
Tim Pinoy
@waeren
Apr 04 2015 18:30
@Sudeepto it was indeed the least common multiple for all numbers in the range that got the challenge solved. Thanks again!
Sudeepto
@Sudeepto
Apr 04 2015 18:55
@waeren No problem. But I should thank you because of you, I revisited Wolfram alpha after such a long time and revised about LCM :P
Suzanne Atkinson
@AdventureBear
Apr 04 2015 21:39
OK, i'm working on the HTML escaped characters bonfire and trying to use a regex, but even the simplest one isn't working for me. If I replace 'reg' with '&' it works fine but not with the regex. What am I doing wrong? Note: I havn't implemented the replace yet, just testing my code / method.
Cristián Berríos
@crisberrios
Apr 04 2015 22:03
for regex you need to use other syntax
like var reg = /x/
not a string
and for matching you use either .test or .match depending on the case
for replace you can use regex too
str.replace(regex,string) (or even functions that work with saved groups)