These are chat archives for FreeCodeCamp/Help

11th
Feb 2015
Cristián Berríos
@crisberrios
Feb 11 2015 00:00 UTC
I think I did it with regex
like str.replace(/([13579])([13579])/g,"$1-$2");
but if you want to do it the way you are doing it, which is fine, you can try not splicing the string but pushing the values into a new one
Briana Swift
@brianamarie
Feb 11 2015 00:04 UTC
I will work on it. One of the most awesome/frustrating things I'm finding is the amount of ways you can solve even small problems. Thank you for your help!
Cristián Berríos
@crisberrios
Feb 11 2015 00:05 UTC
push i
are [i] and [i+1] odd?
> true
push "-"
push [i+1]
> false
push [i+1]
that would be an algorithm to push dashes into a new array
Briana Swift
@brianamarie
Feb 11 2015 00:07 UTC
I see. that makes a lot of sense. @crisberrios and @terakilobyte and @FreeCodeCamp are all awesome. I think I can figure it out from here...if not, you'll see me back soon. :)
Cristián Berríos
@crisberrios
Feb 11 2015 00:08 UTC
:D
Suzanne Atkinson
@AdventureBear
Feb 11 2015 00:43 UTC
spent 12 hours (on and off, not continously), debugging a missing () in an if statement. Live and learn
Cristián Berríos
@crisberrios
Feb 11 2015 00:46 UTC
being able to spot errors faster is part of learning
Suzanne Atkinson
@AdventureBear
Feb 11 2015 00:47 UTC
also learning the patterns...what errors messages suggest what kind of erros
Vince
@Vince33
Feb 11 2015 00:55 UTC
@AdventureBear took me 45 min to find missing "."s in link I cut and paste from the bootstrap page
Cristián Berríos
@crisberrios
Feb 11 2015 00:56 UTC
well... one problem of JS is that doesn't throw too much information when something goes wrong
When you have time, go through "Eloquent JavaScript", it'll give you a better understanding of many aspects of the language
Also, be sure to use an editor with JSHint so you don't crack your head over a missing ;
Suzanne Atkinson
@AdventureBear
Feb 11 2015 00:57 UTC
I'm using WebStrom on the advice of @terakilobyte
but it didn't alert me to the missing ()
;)
thanks I have a PDF of hte book and just can't seem to get captivated by it.
Cristián Berríos
@crisberrios
Feb 11 2015 00:58 UTC
use the online version, as you can execute and modify the examples directly from the site
Vince
@Vince33
Feb 11 2015 00:59 UTC
js does not seem as verbose on the errors as some other languages have worked with
Nathan
@terakilobyte
Feb 11 2015 01:00 UTC
I bet it did alert you ;)
sometimes the way it highlights errors is very subtle
Vince
@Vince33
Feb 11 2015 01:01 UTC
hehe I feel like it throws the same error for everything
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:02 UTC
lol
@terakilobyte if I get adventurous I'll go back adn take them out and see what it says.
here's the pen I've been working on
tedious
but learning bit by bit.
right now it's just randomizing one type of workout,
and I'm starting to calculate a "binning" function to generate different patterns
very incomplete
Cristián Berríos
@crisberrios
Feb 11 2015 01:22 UTC
@AdventureBear
function fill (minSteps, maxSteps, stepSize, steps)
{
  var arr = [];
  var factor = (maxSteps - minSteps) / (steps - 1) ;
  arr[0] = stepSize * minSteps;
  arr[steps-1] = stepSize * maxSteps;
  for (var i = 1 ; i < steps -1 ; i++ ) {
    arr[i] = stepSize * Math.round(minSteps + i*factor);
  }
  return arr;
}
fill(1,10,50,10);
try it :D
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:28 UTC
Trying to figure it out, lol. So this is just ONE of the types of my patterns, right?
I pasted our notes from yesterday into a notes.txt file in my project, lol.
or does that take the pace of this bit of mess ?
             if (randomEndurancePattern[0] === "Pyramid 3") {
                    rounds = Math.floor(parseInt(totalDist.val()) / (6 * 25));
                    practiceSet = randomEndurancePattern[0] + "<br /> Rounds: " + rounds + "<br />";
                }  else if (randomEndurancePattern[0] === "Pyramid 4") {
                    rounds = Math.floor(parseInt(totalDist.val()) / (10 * 25));
                    practiceSet = randomEndurancePattern[0] + "<br /> Rounds: " + rounds + "<br />";
                }   else if (randomEndurancePattern[0] === "Pyramid 5") {
                    rounds = Math.floor(parseInt(totalDist.val()) / (15 * 25));
                    if (rounds<1) {
                        //
                    }
                    practiceSet = randomEndurancePattern[0] + "<br /> Rounds: " + rounds + "<br />";
                }
Cristián Berríos
@crisberrios
Feb 11 2015 01:31 UTC
well... if else if else if else if can be replaced by a switch
the function I wrote just interpolates
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:32 UTC
right. I keep thinking way ahead and how it can be refactored
then I get mentally overwhelmed.
Cristián Berríos
@crisberrios
Feb 11 2015 01:33 UTC
fill(1,5,50,5);
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:33 UTC
I figure as I add types of sets I can expand this array:
Cristián Berríos
@crisberrios
Feb 11 2015 01:33 UTC
fill(1,5,50,5);
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:33 UTC
endurancePatterns = [["Pyramid 3", 1, 2, 3],
                ["Pyramid 4", 1, 2, 3, 4],
                ["Pyramid 5", 1, 2, 3, 4, 5]]
but I realize there are probably better ways to do it.
stepsize in your example would relate to the fixed pool size right?
Cristián Berríos
@crisberrios
Feb 11 2015 01:35 UTC
right
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:36 UTC
Thanks. I think I need a mental break. Or someone else to get inside my head for awhile.
Cristián Berríos
@crisberrios
Feb 11 2015 01:37 UTC
like Do you want to be John Malkovich?
Being John Malkovich
that's it
lost in translation
:P
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:39 UTC
hahah...yes, kind of like that!
BTW, lost in translation was a great movie. I've seen it several times
Cristián Berríos
@crisberrios
Feb 11 2015 01:40 UTC
Me too, pushed me to save money and fulfill my dream of visiting Japan
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:40 UTC
so did you do it?
Cristián Berríos
@crisberrios
Feb 11 2015 01:41 UTC
yes! I miss it everyday :(
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:41 UTC
what do you miss about it?
do you speak japanese?
Cristián Berríos
@crisberrios
Feb 11 2015 01:41 UTC
sadly, no
well... the food
the mixture of ancestral culture with technology
the parks, temples and museums
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:43 UTC
so basically everything?
Cristián Berríos
@crisberrios
Feb 11 2015 01:43 UTC
the wacky and interesting things you find on every street
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:43 UTC
:)
Cristián Berríos
@crisberrios
Feb 11 2015 01:43 UTC
the sense of security
yes
basically everything
But well, I'll return someday
Suzanne Atkinson
@AdventureBear
Feb 11 2015 01:52 UTC
that's the way to think abou tit
Suzanne Atkinson
@AdventureBear
Feb 11 2015 02:45 UTC
function LongestWord(sen) { 
  //var re = "/([A-Z ])/ig";
  //var found = sen.match(re);
  var arr = sen.split(" "), 
      longest = arr[0];


  for (i = 1; i>arr.length; i++) {
    if (arr[i].length > longest.length)
    {
      longest = arr[i];
    }

  }
  // code goes here  
  return longest; 

}
returns only the first word.
any ideas? coderbyte easy...
Cristián Berríos
@crisberrios
Feb 11 2015 02:56 UTC
i>arr.length
loop will execute only 1 time
Suzanne Atkinson
@AdventureBear
Feb 11 2015 02:56 UTC
ugh.
thanks!
better!
now I need to strip out non alphanumerics.
not sure if I should do that before the split
or while checking each word
seems like before split would be best
Suzanne Atkinson
@AdventureBear
Feb 11 2015 03:55 UTC
anyone still hanging around?
trying to get ride of any non=characters in the input sentence for the longest word challege
function LongestWord(sen) { 
  var re = /[^a-z]\ig;

  sen = sen.replace(re,'');
Cristián Berríos
@crisberrios
Feb 11 2015 03:58 UTC
I just got back
regex starts and ends with /
so it would be /[^a-z]/ig
Suzanne Atkinson
@AdventureBear
Feb 11 2015 03:59 UTC
does it need a closing / after the ig?
Cristián Berríos
@crisberrios
Feb 11 2015 04:00 UTC
nope
anything after / are flags
Suzanne Atkinson
@AdventureBear
Feb 11 2015 04:01 UTC
OK
Cristián Berríos
@crisberrios
Feb 11 2015 04:01 UTC
that expression will get rid of spaces too
Suzanne Atkinson
@AdventureBear
Feb 11 2015 04:01 UTC
i think i got it working
right I jsut added a space between the z and the ]
is that an ok way to do it?
/[^a-z ]/ig
Cristián Berríos
@crisberrios
Feb 11 2015 04:02 UTC
yes, there is a way
\s is the expression for space
or more correctly "whitespace"
or more correctly "whitespace", which includes tabs, spaces, new lines... form feed and vertical tab
Suzanne Atkinson
@AdventureBear
Feb 11 2015 04:05 UTC
thanks, this worked:
var re = /[^a-z\s0-9]/ig;
i got dinged for a test case of two "number words" not passing, so I added the numbers
Cristián Berríos
@crisberrios
Feb 11 2015 04:06 UTC
but, matching space as you did it does work, just for single space
Suzanne Atkinson
@AdventureBear
Feb 11 2015 04:06 UTC
regex is interesting but frustrating too.
that easy coderbyte only took me about 3 hours.
:)
Cristián Berríos
@crisberrios
Feb 11 2015 04:06 UTC
also, instead of 0-9 you can use \d
Suzanne Atkinson
@AdventureBear
Feb 11 2015 04:07 UTC
ok, good to know, I remmeber seeing that
no shortcut to replace /[a-z]/i
Cristián Berríos
@crisberrios
Feb 11 2015 04:07 UTC
sure
/[^a-z\s0-9]/ig; == /[^\w\s]/g
except \w also matches "_" (underscore)
Suzanne Atkinson
@AdventureBear
Feb 11 2015 04:09 UTC
sigh. I'll get it eventually
Cristián Berríos
@crisberrios
Feb 11 2015 04:09 UTC
regex is one of the most complex skills to learn
from 1 to 100, if you are at 2, I'm mostly at 3
so don't worry :P
Suzanne Atkinson
@AdventureBear
Feb 11 2015 04:09 UTC
haha. OK, thanks.
i feel better
Cristián Berríos
@crisberrios
Feb 11 2015 04:10 UTC
the worst example is the RFCxxx specification for matching an e-mail address
Bettina Schaden
@bSchaden
Feb 11 2015 04:20 UTC
hi, anyone available to help with dash "esha's restaurant"?
i'm on lesson 3, checkpoint 2, where i set the media query, but it's not responding.
Cristián Berríos
@crisberrios
Feb 11 2015 04:22 UTC
sure
Bettina Schaden
@bSchaden
Feb 11 2015 04:23 UTC
@media (max-width 500px) {
h1 {
font-size: 50px;
margin-top: 20px;
line-height: 40px;
}
}
Cristián Berríos
@crisberrios
Feb 11 2015 04:23 UTC
use ``` before and after the code
@media (max-width 500px) {
h1 {
font-size: 50px;
margin-top: 20px;
line-height: 40px;
}
}
Bettina Schaden
@bSchaden
Feb 11 2015 04:24 UTC
@media (max-width 500px) { h1 { font-size: 50px; margin-top: 20px; line-height: 40px; } }
sorry, I've never asked for help here.
huhhh???
Cristián Berríos
@crisberrios
Feb 11 2015 04:25 UTC
it should be max-width: 500px
Bettina Schaden
@bSchaden
Feb 11 2015 04:27 UTC
@media (max-width 500px) {
  h1 {
    font-size: 50px;
    margin-top: 20px;
    line-height: 40px;
  }
}
Cristián Berríos
@crisberrios
Feb 11 2015 04:28 UTC
(max-width: 500px)
Bin Ury
@teddy-error
Feb 11 2015 05:36 UTC
var fs = require('fs');
var file = process.argv[2];
var count = 0;

fs.readFile(file, function(err, data) { 
    if (err) throw err;
    data.toString().split('').forEach(function(x){
        if (x == '\n')
            count += 1;
    });
});

-> 0
:rage:
global scope is a lie?????
MychaelZ
@MychaelZ
Feb 11 2015 05:37 UTC
i think when u make it toString it elminates the \n
Ryan Malm
@Rybar
Feb 11 2015 05:43 UTC
split at newline instead. read the directions carefully, it covers that gotcha.
lineCount = str.split('\n').length-1;
LOL hacky as hell but totally works.
Suzanne Atkinson
@AdventureBear
Feb 11 2015 05:48 UTC
@teddy-error is that nodeschool?
Bin Ury
@teddy-error
Feb 11 2015 05:50 UTC
yesm
idk I fixed it just by moving the count variable declaration inside of the readFile method
I think it has something to do with the way node manages its global stack
Suzanne Atkinson
@AdventureBear
Feb 11 2015 05:50 UTC
nice. I'm on challenge 11 of the learnyounode challenges.
it hurts my brain
Bin Ury
@teddy-error
Feb 11 2015 05:51 UTC
damn you got ahead of me :D
im on 5.
it hurts but I love these Koan style challenges
on the command line with test assertions and stuff
@Rybar that is so clever
Suzanne Atkinson
@AdventureBear
Feb 11 2015 05:55 UTC
yeah I like them too. between those adn coderbytes it's slow goign right now.
so I entertain myself with some other fun stuff in codepen
Darryl Dixon - Piece Digital
@piecedigital
Feb 11 2015 06:49 UTC
Getting all but one correct answer on this fibonacci problem on bonfire.
The value given to the function called: 75025.
What it wants: 135721.
What I get: 60696.
My code:
function sumFibs(num) {
  var number = 1, oddNum = 0;
  var numray = [1,1];
  for(i = 1; i < num; i++){
    numray.push(numray[i]+numray[i-1]);
  }
  for(j = 0; j< num; j++){
    if(numray[j] % 2 && numray[j] < num){
      oddNum += numray[j];
    }
  }
  return oddNum;
}

sumFibs(4);
This is a Bonfire challenge, by the way.
Cristián Berríos
@crisberrios
Feb 11 2015 06:54 UTC
let's see
well, fibonacci starts with 0 and 1
Darryl Dixon - Piece Digital
@piecedigital
Feb 11 2015 06:56 UTC
"The first few numbers of the Fibonacci sequence are 1, 1, 2, 3, 5..." - From the challenge. So I started it off with [1,1]
Everything else passed, cept the last one.
Cristián Berríos
@crisberrios
Feb 11 2015 06:56 UTC
can you link the challenge?
Cristián Berríos
@crisberrios
Feb 11 2015 06:58 UTC
ok
Nathan
@terakilobyte
Feb 11 2015 06:59 UTC
<hint>that failing test is failing because the value passed in is a fibonacci number</hint>
Cristián Berríos
@crisberrios
Feb 11 2015 06:59 UTC
instructions say "up to and including" if(numray[j] % 2 && numray[j] < num){
Darryl Dixon - Piece Digital
@piecedigital
Feb 11 2015 07:00 UTC
Got it.
It just donned on me
change if(numray[j] % 2 && numray[j] < num){ to if(numray[j] % 2 && numray[j] <= num){
Nathan
@terakilobyte
Feb 11 2015 07:02 UTC
how are you liking bonfire @piecedigital ?
Darryl Dixon - Piece Digital
@piecedigital
Feb 11 2015 07:03 UTC
Much better than coderbyte
MychaelZ
@MychaelZ
Feb 11 2015 09:47 UTC
anyone up that knows git?
Cassandra Cruz
@lambdatastic
Feb 11 2015 09:48 UTC
I’m here, ask away.