These are chat archives for FreeCodeCamp/Help

23rd
Jan 2015
Suzanne Atkinson
@AdventureBear
Jan 23 2015 04:48
question: what's the difference between pattern.test(str) and pattern.match(str)? where pattern = regex pattern
James McShane
@jmcshane
Jan 23 2015 04:52
that's a good question, the difference is in the return value
pattern.test(str) returns a true/false statement if the pattern finds a match
pattern.match(str) returns a "Match" object, which will contain the part of the string that matches and hold information about match groups, indices etc
Suzanne Atkinson
@AdventureBear
Jan 23 2015 04:54
whoa that sounds pretty cool! I don't know how I'll use it yet, but it's cool.
James McShane
@jmcshane
Jan 23 2015 04:55
Suzanne Atkinson
@AdventureBear
Jan 23 2015 04:55
so for most of these coderbyte challenges, at least the easy ones test would work fine it seems?
James McShane
@jmcshane
Jan 23 2015 04:55
that's right
test is also a "cheaper" operation that match is, so it runs much faster
Suzanne Atkinson
@AdventureBear
Jan 23 2015 04:55
cool. yep I was there already (link above). :)
James McShane
@jmcshane
Jan 23 2015 04:55
not as much of a concern now, but good to know in the future
Suzanne Atkinson
@AdventureBear
Jan 23 2015 04:56
what other functions can we use regex in?
lots of others or just afew? testing and matching soudn comprehensive to me.
James McShane
@jmcshane
Jan 23 2015 04:56
there's a few others, this is definitely not a definitive list:
especially exec(), this is an important one
this is really most of what you will need, str.replace(pattern), pattern.test(str), pattern.exec(str), and pattern.match(str)
Suzanne Atkinson
@AdventureBear
Jan 23 2015 05:07
thanks! I think for counting vowels I need something besides test.
Suzanne Atkinson
@AdventureBear
Jan 23 2015 05:23
@jmcshane can you check this code?
function VowelCount(str) { 

  // code goes here  
    var patt = /[aeiou]/g;
    var res = patt.exec(str);
    str = res.length;
  return str; 

}
supposed to return the # of vowels, but it only returns 1. I didn't see .length as a method for the return value of exec, but it's an array isn't it?
Harry Karapetyan
@hk99
Jan 23 2015 05:31
@AdventureBear your regex is fine, I think exec is the problem
try match instead
Suzanne Atkinson
@AdventureBear
Jan 23 2015 05:32
ok
hmm..undefined
aha!
it worked, thanks.
str.match(patt)
not patt.match(str)
Harry Karapetyan
@hk99
Jan 23 2015 05:37
cool, yeah I always confuse those two
Suzanne Atkinson
@AdventureBear
Jan 23 2015 05:38
annoying too, lol.
thanks for the tip.
Harry Karapetyan
@hk99
Jan 23 2015 05:39
just a suggestion - try not to modify str
you can do
function VowelCount(str) { 

  // code goes here  
    var patt = /[aeiou]/g;
    var res = patt.exec(str);
    return res.length;

}
Suzanne Atkinson
@AdventureBear
Jan 23 2015 05:42
I think return str was already in the coderbyte blank coding area? but I guess there's no reason not to do what you did above if it's better and still returns the correct value right?
thanks for the tip
i can see your solution being a 1-liner also.
Ben Clist
@BenClist
Jan 23 2015 05:44
yeah feel free to change the return on the coderbyte stuff, as long as the correct answer is returned they don't mind how
Suzanne Atkinson
@AdventureBear
Jan 23 2015 05:44
return str.match(/[aeiou]/g).length;
Harry Karapetyan
@hk99
Jan 23 2015 05:44
ya no difference here, just saves headaches down the road
Suzanne Atkinson
@AdventureBear
Jan 23 2015 05:44
?? @BenClist thanks. you guys are all very patient and helpful. I love it
yqyeoh
@yqyeoh
Jan 23 2015 06:42
hi guys, i'm doing coderbyte easy challenge 2, finding factorial
function FirstFactorial(num) { 
  var factorial = 1;
  for (int i = 1; i<=num; i++){
    factorial *= i;;
  }
  return factorial;
}
wat is wrong with my code?
david
@dalvarado
Jan 23 2015 06:47
looks like you're confusing java with javascript
should be var i not int i
This message was deleted
This message was deleted
function FirstFactorial(num) { 
  var factorial = 1;
  for (var i = 1; i<=num; i++) {
    factorial *= i;
  }
  return factorial;
}
yqyeoh
@yqyeoh
Jan 23 2015 07:02
ahhhhhhhh
stupid me
thanks
david
@dalvarado
Jan 23 2015 07:05
i do it too :)
Anthony Albertorio
@tesla809
Jan 23 2015 15:36
Hello!
Kamal Sharif
@ksharifbd
Jan 23 2015 15:37
Hello
Jason Rueckert
@jsonify
Jan 23 2015 16:09
morning team!!!
Maxim Orlov
@Maximization
Jan 23 2015 16:13
good morning Jason
Jason Rueckert
@jsonify
Jan 23 2015 16:14
what's the word on the street today?
cerissa
@cerissa
Jan 23 2015 16:23
question, what is a mixin in css? and how would it be used?
Kamal Sharif
@ksharifbd
Jan 23 2015 16:38
@cerissa I've searching for answers for this question. Just stumbled on SASS website. Hope it helps you>>http://sass-lang.com/guide
cerissa
@cerissa
Jan 23 2015 16:39
oh ok so its sass and not css
Kamal Sharif
@ksharifbd
Jan 23 2015 16:40
Also I've found this Youtube channel of SASS tutorial>> https://www.youtube.com/playlist?list=PL2CB1F80266E986EA
Ben Stoltz
@benstoltz
Jan 23 2015 16:43
Mixins exist in pretty much all CSS pre-processors. SASS and LESS.
cerissa
@cerissa
Jan 23 2015 17:00
ok thanks
cerissa
@cerissa
Jan 23 2015 22:35

going thru some javascript, was wondering if i had this correct.
$(this).closest("li").remove();

would this just remove the list item? is that what closest('')remove() mean?