These are chat archives for FreeCodeCamp/Help

22nd
Mar 2015
William
@KathyTheTurtle
Mar 22 2015 02:10
@McQuinTrix right.. I was definitely overthinking it
Harshal
@McQuinTrix
Mar 22 2015 02:11
@KathyTheTurtle let me know if you face problem (: .. i was able to find my code :3
William
@KathyTheTurtle
Mar 22 2015 02:13
@McQuinTrix thanks a lot :)
Viacheslav
@Stee1House
Mar 22 2015 04:07
Hello everyone, who can help with bonfires - http://www.freecodecamp.com/bonfires/where-do-i-belong
Harshal
@McQuinTrix
Mar 22 2015 04:08
@Stee1House have you tried solving it ?
(:
Viacheslav
@Stee1House
Mar 22 2015 04:21
function where(arr, num) {
  for(var i = 0; i < arr.length; i++) {
 //ddd   if(arr[i + 1] > num || arr[i] < num || arr[i] == num) {
      return i;
    }
  }
}
Harshal
@McQuinTrix
Mar 22 2015 04:24
@Stee1House just check one thing .. if lesser than ..
Viacheslav
@Stee1House
Mar 22 2015 09:23
@McQuinTrix okay
anyway on't work
function where(arr, num) {
  for(var i = 0; i < arr.length; i++) {
    console.log(arr[i] + " < " + num + " && " + arr[i + 1] + " > " + num)
    if(arr[i] < num && arr[i + 1] > num || num == arr[i])
    return i + 1;
  }
}
Viacheslav
@Stee1House
Mar 22 2015 09:55
all work, thanks
Catalin Iosif
@ciosifweb
Mar 22 2015 12:16
hello, campers
kian
@meecoder
Mar 22 2015 12:16
@ciosifweb hello
Catalin Iosif
@ciosifweb
Mar 22 2015 12:17
can someone send me a screenhero invite, as I'm not able to sign up on my own.
?
kian
@meecoder
Mar 22 2015 12:18
@ciosifweb use this link, you can sign up within screenhero once you download it http://freecodecamp.com/install-screenhero
Catalin Iosif
@ciosifweb
Mar 22 2015 12:19
thanks, Kian
Lucas
@cieslakslash
Mar 22 2015 13:49

hi, guys, a need a help, im doing a stanford course and i have q1: Write code to count and print number of names starting with the letter "O". The last line printed should look like the "count: 23" example above (of course the answer is not 23). You can print out rows or other things in the loop too if you like, so long as the "count: 23" line appears at the end.

So I did something like that:
table = new SimpleTable("baby-2010.csv");
count = 0;
for (row: table) {
// your code here
if (
row.getField("name").startsWith("O")){
count = count + 1;
}
}
print("count:", count);

It counts 12 and i need to have 23. So I added other things like "gender or rank" and I got number 23, but It does not want to accept it. So I added "count = count +2" and then i add "print("count:", count - 1", and it show 23, but it does not want to accept it...

any tips?

Catalin Iosif
@ciosifweb
Mar 22 2015 13:55
hello @cieslakslash
I think that line is about the format you should be printing your answer
and not the actual number
it should accept 12
Lucas
@cieslakslash
Mar 22 2015 14:02
oh god, ty u r right, im so stupid...
:(
Catalin Iosif
@ciosifweb
Mar 22 2015 14:04
no, you're not
it's easy to slip up when you're going through a lot of material
Lucas
@cieslakslash
Mar 22 2015 14:04
anyway, thank you :)
Catalin Iosif
@ciosifweb
Mar 22 2015 14:05
you're welcome, keep at it :smile:
Sergej
@BSS555
Mar 22 2015 15:32

Remove all falsey values from an array.

function bouncer(arr) {
        // Don't show a false ID to this bouncer.
        var list = [false, null, 0, "", undefined, NaN];
        for (var i = 0; i < arr.length; i++) {
            for (var j = 0; j < list.length; j++) {
                if (arr[i] === list[j])
                    arr.splice(i, 1);
            }   
        }
      return arr;
    }

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

It don't remove the "false" from the array. Help pls

Kapil Dutta
@duttakapil
Mar 22 2015 16:20
I don't understand the Convert HTML Entities Bonfire
I run the tests and it says, "'Dolce & Gabbana' to equal 'Dolce & Gabbana'"
:/
@BSS555 you might want to use a filter() for that.
Oliver
@Dadsaster
Mar 22 2015 17:45
@BSS555 You don't need an array of falsey values. If you remember when you write an if statement what you put in the statement is evaluated. so if (arr[i] === "false") will evaluate to true when arr[i] is a falsey and evaluate to false when arr[i] is \a truthy.
Bianca Mihai
@biancamihai
Mar 22 2015 19:50
@BSS555 first for in for => O(n*n) execution time, there are 2 solutions here, you can use an additional array and loop once trough the arr and if the value is not "false" then push it into the new array => return this array
@BSS555 the second solution, if you don't want to use a new array and want to work on arr then don't use the for structure, because you loop trough the arr and you splice the elements are shifted, the length and the position is changed, so I think you should use a while structure and take care at the length and position ...
Bianca Mihai
@biancamihai
Mar 22 2015 19:57
@duttakapil I think it refers to <, >, " and &
&lt;, &gt;, &quot; and &amp;
4TSG4X
@4TSG4X
Mar 22 2015 20:57
Anyone up for some coding?
Harshal
@McQuinTrix
Mar 22 2015 23:44
@piecedigital hey ..can I learn from Node up and running book rather follow nodeschool.io thing ?
Darryl Dixon - Piece Digital
@piecedigital
Mar 22 2015 23:46
@McQuinTrix Yeah, then you can come back and complete the nodeschool challenges. Depending on how old the book it I think you should fact check everything you've read in case there are differences in the version.
Are you struggling with NodeSchool?
Harshal
@McQuinTrix
Mar 22 2015 23:48
yeah man, from second challenge .. how to use the argv ? .. i have never used in JavaScript before .. and also as said by Quincy .. it is not so fun to code with it .. many of things seem bursting from the air