These are chat archives for FreeCodeCamp/Help

27th
Jun 2015
cblupodev
@cblupodev
Jun 27 2015 00:12
I use chromeos, so the recommended screen sharing software won't work on my machine. Does the freecodecamp community have a fallback for it's users to screen share with?
Jad Chaar
@jadchaar
Jun 27 2015 00:17

Hey guys,

I am stuck on the jQuery Events: Hover activity. This is the code I wrote but for some reason the editor is not accepting it:

$(document).ready(function(){

$('div').hover(
function(){
$(this).addClass('active');
},
function(){
$(this).removeClass('active');
}
);

});

Anyone know what’s wrong?

sowpat
@sowpat
Jun 27 2015 00:27
blob
Hey, so my code for the seek and destroy bonfire is not working does anyone know why, here is my code:
Thanks!
@JC713 is this from the code academy lessons on jQuery?
Because if so, underneath the instructions there is a link to the discussions forum and if you look through the posts there is almost always an answer to whatever excercise you're on
Scott
@macengr
Jun 27 2015 00:36
@FFX01 I figured it out - thanks for the help!
sowpat
@sowpat
Jun 27 2015 00:40

```function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments);

return arr.filter(function(element){
return args.slice(1).indexOf(element) === -1;
});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);```

Can anyone explain what's going on in the code above?
BaxterChi
@BaxterChi
Jun 27 2015 01:18
@sowpat Your first For loop looks pretty weird. And I don’t think you really need it
yeah your first for loop isn’t doing anything
Howard-S
@Howard-S
Jun 27 2015 02:32
Is there a way to find out if there is a bug in one of the assignments? I cant figure out what my problem is. I had someone help me earlier but its still not working
Jad Chaar
@jadchaar
Jun 27 2015 02:34
@sowpat Thanks, I’ll check it out!
Sophanarith Sok
@sok213
Jun 27 2015 02:38
Hi, Can someone ELI5 the instructions of Bonfire: Convert HTML Entities. I dont get what it is telling me what to do.
Mathieu Roy
@Mathieu-Roy
Jun 27 2015 02:42
Has anyone done Bonfire: Symmetric Difference?
@sok213 the tests for this bonfire doesn't work at the moment by the way; but what you would have to do basically is to replace & with &amp ; for example, because & is a special character, so it needs to be escaped (see the links on the page)
Sophanarith Sok
@sok213
Jun 27 2015 02:46
@Mathieu-Roy No wonder the test was confusing me. Thanks!
Mathieu Roy
@Mathieu-Roy
Jun 27 2015 02:46
@Howard-S hmm, can you show me your code so I can better understand what you're looking for
this is the requirement Each of your Bootstrap buttons should be wrapped within its own a div element with the class "col-xs-4"
<div> <button class='btn btn-block btn-primary col-xs-4'>Like</button></div>
<div> <button class='btn btn-block btn-info col-xs-4'>Info</button></div>
<div> <button class='btn btn-block btn-danger col-xs-4'>Delete</button></div>
Sophanarith Sok
@sok213
Jun 27 2015 02:49
You have to add class='col-xs-4' within the <div> tag
Robert Ozimek
@robertozimek
Jun 27 2015 02:49
they mean this
<div class = “col-xs-4">
<div> <button class='btn btn-block btn-primary'>Like</button></div>
<div> <button class='btn btn-block btn-info'>Info</button></div>
<div> <button class='btn btn-block btn-dange'>Delete</button></div>
</div>
@Howard-S
Howard-S
@Howard-S
Jun 27 2015 02:50
i'll try that
@robertozimek still didnt accept it
Mathieu Roy
@Mathieu-Roy
Jun 27 2015 02:51
@Howard-S you have to surround each of your button with <div class="col-xs-4"></div>
@Howard-S each individually; such as:
<div class="col-xs-4"> <button class='btn btn-block btn-primary'>Like</button></div>
Robert Ozimek
@robertozimek
Jun 27 2015 02:52
@Howard-S I just read the waypoint and @Mathieu-Roy is right
each button needs its own div with that class
Howard-S
@Howard-S
Jun 27 2015 02:52
@Mathieu-Roy ill try that too @robertozimek ok thanks
Mathieu Roy
@Mathieu-Roy
Jun 27 2015 02:54
@Howard-S and you surround all (not each) buttons with <div class="row"> </div>
@Howard-S does it work?
Howard-S
@Howard-S
Jun 27 2015 02:55
@Mathieu-Roy it did - - 2 hours later! Thanks all
Mathieu Roy
@Mathieu-Roy
Jun 27 2015 02:56
@Howard-S good perseverance!
Howard-S
@Howard-S
Jun 27 2015 02:56
subborn is more like it
Mathieu Roy
@Mathieu-Roy
Jun 27 2015 02:56
@Howard-S stubborn is good too ;)
Howard-S
@Howard-S
Jun 27 2015 02:57
thanks - time to get off this computer now! see you next problem
J.Gary Picard
@mrpickens
Jun 27 2015 03:31
Override Styles with Important is the task-My last issue is to input the element "class 'blue-text within the <h2. I have tried everything and I need help!
Don
@raydancer
Jun 27 2015 03:50
Can someone tell me why my primeCheck function is only returning false?
function sumPrimes(num) {
  var primeSum = 0;
  for (var i = 2; i < num; i++){
    if (primeCheck(i) === true){
      primeSum += i;
      console.log(primeSum);
    }
  }
  return primeSum;
}

function primeCheck(test){
  var primeArr = [];
  for (var i = 1; i <= test; i++){
    if (test % i === 0){
    }
  }
  if (primeArr === [1, test]){
    return true;
  } else {
    return false;
  }
}

sumPrimes(10);
Prashanth Chandra
@prashcr
Jun 27 2015 03:53
I don't understand your logic
you're loop doesn't do anything
*your
so you have an empty array
which is != [1, test]
I think you're missing a primeArr.push(i) inside the if block
Don
@raydancer
Jun 27 2015 03:55
yep...I just saw that; getting late...thanks
@prashcr hmm...even when I added the push, they still compare as false...
Prashanth Chandra
@prashcr
Jun 27 2015 04:00
yeah
because when you use === on objects you're comparing the object reference not the contents
so [1,2] === [1,2] would be false because they're two different objects
You have to loop through the array and compare
Don
@raydancer
Jun 27 2015 04:05
thanks @prashcr
Stephanie Morrison
@Stephaceae
Jun 27 2015 04:53
help? I’m on Waypoint: Get Started with jQuery - On the CodeAcedemy website, and the click me button doesn’t appear, so I can’t move onto the next challenge. I switched to chrome, and the button appeared until I added the code to link the index.html to the js.script
*script.js
<script type='text/javascript' src='script.js'> 
<html>
    <head>
        <title>Button Magic</title>
        <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
    </head>
    <body>
     <div><br/><strong>Click Me!</strong></div>   
    </body>
</html>
</script>
Stephanie Morrison
@Stephaceae
Jun 27 2015 05:02
The ‘click me button’ appears when I remove the <script> code in chrome
Jeff Wilkey
@JeffWilkey
Jun 27 2015 05:29
put the script tag below your body
@Stephaceae
Stephanie Morrison
@Stephaceae
Jun 27 2015 05:30
@JeffWilkey thanks! I moved over to FCC chat, they are now having a discussion explaining why we put it below the body and the reasons for exceptions
Jeff Wilkey
@JeffWilkey
Jun 27 2015 05:30
Ahh gotcha! @Stephaceae haha Glad you got it figured out.
jlin14
@jlin14
Jun 27 2015 05:39
am I missing something obvious or is there no native hashset/hashmap
Stjepan Mazalovic
@stjema
Jun 27 2015 06:16
moinm oin leute
that's german
tjstinso
@tjstinso
Jun 27 2015 07:10
@jlin14 there is not
ar2g
@ar2g
Jun 27 2015 10:46
I'm a bit confused about the first zipline, anyone able to help?
Stjepan Mazalovic
@stjema
Jun 27 2015 10:51
nope
ar2g
@ar2g
Jun 27 2015 10:55
ok :(
tjstinso
@tjstinso
Jun 27 2015 11:00
what are you having trouble with? im working on it myself
ar2g
@ar2g
Jun 27 2015 11:21
OAuth with the twitchtv API
@tjstinso as in - which authorisation mechanism to use, how to store the secret that sort of thing
Vos
@KrisVos130
Jun 27 2015 11:29
Could anyone maybe help me with the Functional Programming waypoint? I find those 5 methods really hard to use and I keep forgetting which one does what with what arguments and what I then need to return
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:30
@ar2g you don't need to authenticate to use the twitch api
tjstinso
@tjstinso
Jun 27 2015 11:32
^ can just use getJSON
Danny Lewis
@silverwedding
Jun 27 2015 11:36
Can anyones help me with Bonfire: Convert HTML Entities?
ar2g
@ar2g
Jun 27 2015 11:37
@ekojsalim @tjstinso well I tried and get: XMLHttpRequest cannot load https://api.twitch.tv/kraken/streams/freecodecamp. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access.
tjstinso
@tjstinso
Jun 27 2015 11:38
ah
its
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:38
@silverwedding that exercise has bugs for <>
tjstinso
@tjstinso
Jun 27 2015 11:38
$.getJson(https://api.twitch.tv/kraken/streams/" +str+ ".json?callback=?)
quots around that link
and replace str with the channel
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:38
@ar2g yeah you need to send a jsonp request
ar2g
@ar2g
Jun 27 2015 11:38
aha ok I see @tjstinso @ekojsalim - thank you I'll try that
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:39
if you use getJSON add ?callback=? to end of your url like @tjstinso said
Stjepan Mazalovic
@stjema
Jun 27 2015 11:41
var number = 0;
while (number <= 12) {
  console.log(number);
  number =+ 2;
}
infinite loop. why? if i write number += 2; then i only loops till 12
the long version is number = number + 2; if we shorten it: number =+ 2 and not number += 2
first the equal sign, then the +
Danny Lewis
@silverwedding
Jun 27 2015 11:43
@ekojsalim ok yeah that's what i was having a problem with
Stjepan Mazalovic
@stjema
Jun 27 2015 11:43
but in the short version it's first + and then =, why? oOOOO
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:44
@stjema okay
Stjepan Mazalovic
@stjema
Jun 27 2015 11:44
unnecessary question
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:44
@stjema += here is not valid
Stjepan Mazalovic
@stjema
Jun 27 2015 11:44
but why not. would make more sense because it's like the long version
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:44
you are basically assigning the number to the value 2
Stjepan Mazalovic
@stjema
Jun 27 2015 11:44
i kno.
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:45
what is +2
if you type that in a console you will get 2
and you are basically assigning that to number
with number =
you can think this as number = +2
Stjepan Mazalovic
@stjema
Jun 27 2015 11:45
but why does it make an infinite loop?
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:46
you are assigning the value two to number
it will never reach 12
Stjepan Mazalovic
@stjema
Jun 27 2015 11:46
oh lol
XDDDDDDD
thank you XD now i understood
stjema @stjema hugs @ekojsalim
Eko Julianto Salim
@ekojsalim
Jun 27 2015 11:46
:)
Stjepan Mazalovic
@stjema
Jun 27 2015 11:47
where you from?
Destino Dello
@destino92
Jun 27 2015 11:59
can anyone help me with this code please? SUM ALL ODD FIBONACCI NUMBERS
function fib(num){
 var fib = [0,1];
 var sum = 1;

    for(i=2; i<=num; i++)
    {
      fib[i] = fib[i-2] + fib[i-1];

      if(fib[i]%2)
      {
        sum+=fib[i];
        console.log(sum);
      }

    }

  return sum;

}
Stjepan Mazalovic
@stjema
Jun 27 2015 12:00
to hard for me sry
Rasheed Bustamam
@abustamam
Jun 27 2015 12:01
what are you getting @destino92 ?
Destino Dello
@destino92
Jun 27 2015 12:02
expect(sumFibs(1)).to.be.a('number');
expect(sumFibs(1000)).to.equal(1785);
expected 11708364174233842 to equal 1785
expect(sumFibs(4000000)).to.equal(4613732);
expected 11708364174233842 to equal 4613732
expect(sumFibs(4)).to.equal(5);
expect(sumFibs(75024)).to.equal(60696);
expected 11708364174233842 to equal 60696
expect(sumFibs(75025)).to.equal(135721);
expected 11708364174233842 to equal 135721
@abustamam it is not working with number that higher than 2 digits and giving the same answer
tjstinso
@tjstinso
Jun 27 2015 12:25
set your if statement to fib[i] % 2 != 0
Karan Joisher
@karanjoisher
Jun 27 2015 12:33
Bonfire: Binary Agents ... do i need to convert binary into ascii for this?
??
ar2g
@ar2g
Jun 27 2015 12:53
another call for help on the twitch zipline... how do you tell if the channel is online or not?
Destino Dello
@destino92
Jun 27 2015 12:55
@tjstinso i have tried it's the same logic if i%2 equal 0 the if doesn't work hence it's an even number
@CodeNonprofit any idea on what is wrong in my code?
Eko Julianto Salim
@ekojsalim
Jun 27 2015 13:12
@destino92
function sumFib(num){
    var fib = [0, 1];
    var sum = 1;

    for(var i = 2; fib[fib.length - 1] + fib[fib.length - 2] <= num; i++)
    {
        fib[i] = fib[i - 2] + fib[i - 1];

        if(fib[i] % 2)
        {
            sum += fib[i];
        }

    }
    return sum;

}
that should be workign
i here does not correspond to the current number
i represents the index
that is what is wrong with your code
don't use a name twice for a variable
(the fib function and fib array)
Eko Julianto Salim
@ekojsalim
Jun 27 2015 13:17
fib[i] % 2 is working because of javascript type coercion
Destino Dello
@destino92
Jun 27 2015 13:20
@ekojsalim thank completely left it out
Eko Julianto Salim
@ekojsalim
Jun 27 2015 13:22
:)
ronaldrdguez
@ronaldrdguez
Jun 27 2015 13:29
Morning everyone, have a quesiton on the Exact Change bonfire, when returning change, is it in the same 2d array format as cid?
Stjepan Mazalovic
@stjema
Jun 27 2015 13:40
@ekojsalim he has a question
Paul Soper
@pdsoper
Jun 27 2015 13:42
@ar2g The API documentation at https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamschannel shows you the difference in the JSON for online and offline streams.
Eko Julianto Salim
@ekojsalim
Jun 27 2015 13:45
@ronaldrdguez if you haven't figured it out, you should return an array containing the change in multiple denominator sorted descendingly
@stjema sorry for not answering your previous question, I am from Indonesia :)
Stjepan Mazalovic
@stjema
Jun 27 2015 13:46
:D ok
ronaldrdguez
@ronaldrdguez
Jun 27 2015 13:54
Thanks @ekojsalim Would something like this work, I’m trying to figure the correct format for the output, unfortunately the tests don’t help to clarify. A sample output would be nice.
[['ONE HUNDRED', ??? ],['TWENTY', ??? ], ['TEN', ??? ], ['FIVE', ???], …]
Eko Julianto Salim
@ekojsalim
Jun 27 2015 13:56
@ronaldrdguez yeah, this is one of the tests answer [['TWENTY', 60.00], ['TEN', 20.00], ['FIVE', 15], ['ONE', 1], ['QUARTER', 0.50], ['DIME', 0.20], ['PENNY', 0.04] ]
ronaldrdguez
@ronaldrdguez
Jun 27 2015 14:01
@ekojsalim Indeed, I read past it and didn’t see it. Looks like I need more coffee. Thank yoy very much!
cblupodev
@cblupodev
Jun 27 2015 14:04
Eko Julianto Salim
@ekojsalim
Jun 27 2015 14:11
@cblupodev you have a that should not be there
cblupodev
@cblupodev
Jun 27 2015 14:13
@ekojsalim oh. my. god. Thanks
Eko Julianto Salim
@ekojsalim
Jun 27 2015 14:13
no problem :)
NguyenVu06
@NguyenVu06
Jun 27 2015 15:39

I'm on the style exercise with the following code: <Style>h2{color:blue;}</Style>

<h2>CatPhotoApp</h2>

<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>

I keep getting the error :"Make sure each of your style elements has a closing tag."
I"m not sure what closing tag the website is talking about
Colin H.
@clnhll
Jun 27 2015 16:18
Does anyone know anything about async/socket.io
Cristián Berríos
@crisberrios
Jun 27 2015 16:24
I've tried socket.io once but I'm not by any means an expert using it
Colin H.
@clnhll
Jun 27 2015 16:31
I've got a problem that has to do with latency or async or something
I have a function that is called to redraw a chart with some data when the database with that data changes
it works fine locally, but when I push it to a production server, the function is called before the data arrives
I've fixed it by passing a timeout with the callback function but that's a poor coding practice
so it looks like this now
socket.syncUpdates('stock', $scope.stocks,function(event, stock, stocks) { setTimeout(function(){$scope.refreshChart();},500); });
thoughts?
ciper99
@ciper99
Jun 27 2015 16:39
hey, is this the equivalent of the #help channel in slack?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 16:40
yes
ciper99
@ciper99
Jun 27 2015 16:40
what happened to slack?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 16:40
it couldn't hold everyone.
ciper99
@ciper99
Jun 27 2015 16:41
ohh
too bad, I liked it there
I don't usually like change, it's the second time we get back to gitter
why did we leave in the first place?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 16:44
quincy thought slack would be better. He wrote a long blog post about it...you can get all caught up
ciper99
@ciper99
Jun 27 2015 16:45
oh ok, thanks
I liked slack a lot
I need help understanding something in bonfire finders keepers
could you help me?
I have solved the bonfire
Suzanne Atkinson
@AdventureBear
Jun 27 2015 16:45
what's your question, I'll try
ciper99
@ciper99
Jun 27 2015 16:46
I don't understand array.some
specifically
I don't understand how I am supposed to access the value for which I it returns true
I only know that it returns true if the condition is met, and false otherwise
I did it without it, by going through the array with a loop
this was my solution

´´´ function find(arr, func) {
for (var i = 0; i < arr.length; i++){
if (func(arr[i])){
return arr[i];
}
}

}´´´7

oops, my formatting failed
anyhow, how can I do it with array.some?
do you know?

´´´function find(arr, func) {
for (var i = 0; i < arr.length; i++){
if (func(arr[i])){
return arr[i];
}
}

}´´´

```function find(arr, func) {
for (var i = 0; i < arr.length; i++){
if (func(arr[i])){
return arr[i];
}
}

}```

code

codefunction find(arr, func) {
for (var i = 0; i < arr.length; i++){
if (func(arr[i])){
return arr[i];
}
}

}code

ciper99
@ciper99
Jun 27 2015 16:51
I can't format it, ugh!
can someone help me?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 16:54
You need to hit shift-enter after the 3 ticks and after your code before the closing 3 ticks to format it
ciper99
@ciper99
Jun 27 2015 16:55
oh ok, thanks, let me try again
do you have a solution that uses array.some?

```
function find(arr, func) {
for (var i = 0; i < arr.length; i++){
if (func(arr[i])){
return arr[i];
}
}

}

function find(arr, func) {
  for (var i = 0; i < arr.length; i++){
    if (func(arr[i])){
        return arr[i];
        }
  }

}
ah, finally got that
anyhow, @AdventureBear, do you have a solution with array.some?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:01
actually I don't, i have a solution using filter, which is pretty straightforward.
I just tried to do it using some and can't get it to work because I can't figure out how to access the index, since the function is being passed and I can't presumably modify it.
Someone else might have a better idea!
ciper99
@ciper99
Jun 27 2015 17:02
it's exactly the same problem I got ahahah
what is your solution?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:02
your solution is basically the long version of filter..can you solve it with filter? AT least that's a functional solutoin (higher order) along the lines of some
ciper99
@ciper99
Jun 27 2015 17:03
ok, let me try it with filter
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:03
try it first with filter. If you can't get it, PM me later and I"ll help you. It's worth trying first
ciper99
@ciper99
Jun 27 2015 17:04
done with filter
super simple
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:04
right!
even Nathan solved it with filter.
i think that's who helped me
ciper99
@ciper99
Jun 27 2015 17:09
I mean, it's really simple with filter
but I wanna do it with some
I just don't understand, how can I get the index of the element that returns true?
find his solution... he's the one that wrote the bonfire library...check how he solved finders keepers.
ciper99
@ciper99
Jun 27 2015 17:11
oh kewl
his solution is with filter
and shift
Justin Walters
@FFX01
Jun 27 2015 17:13
This message was deleted
ciper99
@ciper99
Jun 27 2015 17:15
function sumPrimes(num) {
var sum=0;
var isPrime=function(number){
if(number%2===0){
return false;
}
var limit=number-1;
for(var i=2;i<limit;i++){
if(number%i===0){
return false;
}
return true;
}
};
for(var i=2;i<=num;i++){
if(isPrime(i)){
sum+=i;
}
}
return sum;
}
sumPrimes(10);
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:15
@FFX01 use backticks, not single quotes for formatting...located below the tilde, upper left on my keyboard
OH...good work. :)
ciper99
@ciper99
Jun 27 2015 17:15
here is your formatted code, though it lost indentation
hehe @AdventureBear it's all thanks to you
Justin Walters
@FFX01
Jun 27 2015 17:16
@AdventureBear & @ciper99 Thank you so much!
haha
i had no idea why the formatting didnt work
ciper99
@ciper99
Jun 27 2015 17:17
it's with `, not´ or '
Justin Walters
@FFX01
Jun 27 2015 17:17
Let me try it with the indentation.
This message was deleted
ciper99
@ciper99
Jun 27 2015 17:18
no, you gotta press shift and then that key
Justin Walters
@FFX01
Jun 27 2015 17:18
function sumPrimes(num) {
  var sum=0;
  var isPrime=function(number){
    if(number%2===0){
      return false;
    }
    var limit=number-1;
    for(var i=2;i<limit;i++){
      if(number%i===0){
        return false;
      }
      return true;
    }
  };
  for(var i=2;i<=num;i++){
    if(isPrime(i)){
      sum+=i;
    }
  }
  return sum;
}

sumPrimes(10);
I got it!
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:18
so it's not returning 1,2,3 as prime numbers
ciper99
@ciper99
Jun 27 2015 17:19
yeah, first things first
in the beginning if statement, include an AND clause to check if the number isn't 2
Justin Walters
@FFX01
Jun 27 2015 17:20
ok, I'll try that
ciper99
@ciper99
Jun 27 2015 17:21
This message was deleted
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:21
is 1 a prime? I don't remmeber
ciper99
@ciper99
Jun 27 2015 17:21
no
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:21
it's basically just returnign odd numbers right now:
ciper99
@ciper99
Jun 27 2015 17:22
the only prime number which is divisible by 2 is two itself
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:22
thanks, memory refreshed!
I changed one character in your code from that replit I pasted and it works now (I think). Seems to return primes
well, except for the 2 & 3.
so a few logic bits.
the code itself runs, it's the prime checking that's not working just right
Justin Walters
@FFX01
Jun 27 2015 17:25
This returns 2&3
function sumPrimes(num) {
  var sum=0;
  var isPrime=function(number){
    if(number%2===0&&number!==2){
      return false;
    }
    var limit=number-1;
    for(var i=0;i<limit;i++){
      if(number%i===0&&i!==2){
        return false;
      }
      return true;
    }
  };
  for(var i=0;i<=num;i++){
    if(isPrime(i)){
      sum+=i;
    }
  }
  return sum;
}

sumPrimes(10);
but it also returns 9
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:27
OK, for starters, there is a way to optimize your limit loop a little better.
you don't have to start at i=0 since you've already eliminated some options.
and you don't need to go clear up to limit either.
Justin Walters
@FFX01
Jun 27 2015 17:28
for the limit loop if i don't start at i= 0, it doesn't return 2 or 3
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:29
For example if you're checking the number 24, and you've checked for division by 2, 3, 4, 6, 8 ... there's no need to check for 12, right?
ciper99
@ciper99
Jun 27 2015 17:29
@FFX01, why don't you try reading some famous algorithms to find primes, and try to modify or implement one of then
?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:29
for that matter you don't need to check for 6 or 8 either.
ciper99
@ciper99
Jun 27 2015 17:29
I based my solution on the sieve of erasthotenes
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:29
so did I
Justin Walters
@FFX01
Jun 27 2015 17:29
@ciper been trying that. Tryed the euler sieve method as well, but it breaks for some reason
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:30
it just needs some tweaking
Justin Walters
@FFX01
Jun 27 2015 17:30
I'll try it again from scratch
John Ellis
@johnmellis
Jun 27 2015 17:30
Anyone ever setup a local copy of FCC?
I got everything installed, but something w/ my .env file isn’t working right
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:31
@FFX01 if you get stumped, here is something fun I made after solving the bonfire. http://codepen.io/AdventureBear/full/aOoqaV/
Justin Walters
@FFX01
Jun 27 2015 17:32
@AdventureBear pretty cool, but it doesn't return 3
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:33
now it does, thanks. :)
Justin Walters
@FFX01
Jun 27 2015 17:33
yep. good job
ciper99
@ciper99
Jun 27 2015 17:33
I found the bug
it should be if n<=3
right?
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:33
yes I just added the "="
Justin Walters
@FFX01
Jun 27 2015 17:33
I'm going to try and do something like this:
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:34
wonder fi that was missing in my bonfire and it passed anyway?
Justin Walters
@FFX01
Jun 27 2015 17:34
function isPrime2(n) {
 if (isNaN(n) || !isFinite(n) || n%1 || n<2) return false; 
 if (n%2==0) return (n==2);
 var m=Math.sqrt(n);
 for (var i=3;i<=m;i+=2) {
  if (n%i==0) return false;
 }
 return true;
}
Suzanne Atkinson
@AdventureBear
Jun 27 2015 17:34
something along those lines should work a little better I think. I didn't reason it all out though...
Justin Walters
@FFX01
Jun 27 2015 17:35
yeah, the guy whose blog i found that on seems pretty experienced
Justin Walters
@FFX01
Jun 27 2015 17:52
this works for small numbers, but not for large ones:
function sumPrimes(num) {
  var sum=0;
  var isPrime=function(n){
    if(n===1){return false;}
    else if(n===2){return true;}
    else if(n===3){return true;}
    else{
      for(var i=Math.floor(Math.sqrt(n));i>=2;i--){
        if(n%i===0||n%2===0||n%3===0){
          return false;
        }
      }
    }
    return true;
  };
  for(var i=0;i<num;i++){
    if(isPrime(i)){
      sum+=i;
    }
  }
  return sum;
}
sumPrimes(10);
Lightwaves
@Lightwaves
Jun 27 2015 17:52
I was stuck on generating primes.
but got it once I saw the isPrime function
Lightwaves
@Lightwaves
Jun 27 2015 17:58
@FFX01 try -=2 in the for loop it might work slightly better
That should at least skip all the even numbers
actually nvm
I see what you did
Justin Walters
@FFX01
Jun 27 2015 18:00
i'm taking a new approach because that code doesn't work on larger numbers
Lightwaves
@Lightwaves
Jun 27 2015 18:00
I wish I knew how to implement a sieve for getting prime numbers
that'd be more efficient
I got stuck on the lcm the way I was doing it was too much math in heavily nested loops so it was too slow :(
but I'm going to look for factors
so instead of going up to sqrt(n)
I'm going to go up to n/2
my next attempt will be a bit similar isPrime, trial division but
pretty much I'm going to try get factors of both
filter factors not shared by a and b
Justin Walters
@FFX01
Jun 27 2015 18:05
@Lightwaves that's not a bad idea
Lightwaves
@Lightwaves
Jun 27 2015 18:05
then multiply reduce to get the gcf
Justin Walters
@FFX01
Jun 27 2015 18:06
This is the simplest solution I came up with:
function sumPrimes(num) {
  var sum=0;
  var isPrime=function(n){
    if(n===0){return false;}
    else if(n===1){return false;}
    else if(n===2){return true;}
    else if(n===3){return true;}
    else{
      for(var i=2;i<n;i++){
        if(n%i===0){
          return false;
        }
      }
      return true;
    }
  };
  for(var i=0;i<=num;i++){
    if(isPrime(i)){
      sum+=i;
    }
  }
  return sum;
}
sumPrimes(977);
Lightwaves
@Lightwaves
Jun 27 2015 18:09
Using isPrime2 that you posted I used this to pass going to see if I can redo it but learn how to implement a sieve.
function isPrime2(n) {
 if (isNaN(n) || !isFinite(n) || n%1 || n<2) return false; 
 if (n%2==0) return (n==2);
 var m=Math.sqrt(n);
 for (var i=3;i<=m;i+=2) {
  if (n%i==0) return false;
 }
 return true;
}

function sumPrimes(num) {
  primes = [];
  for (var i = 0; i<=num; i++){
    if (isPrime2(i)){
      primes.push(i);
    }

  }
  return primes.reduce(function(a,b){
    return a+b;
  });
}
sumPrimes(200487);
Justin Walters
@FFX01
Jun 27 2015 18:10
I tried the sieve method, but I just couldn't get it to not return 9
Lightwaves
@Lightwaves
Jun 27 2015 18:29
well I got a working gcf algo
Just hoping the rest works as planned /crosses fingers
Justin Walters
@FFX01
Jun 27 2015 18:31
I'm working on the gdm right now. Trying to figure out how to do it without generating a billion arrays.
Lightwaves
@Lightwaves
Jun 27 2015 18:37
wow that was somewhat long but I got it
I feel much better about this one then the isPrime haha
I only had to generate 4 arrays lol
factors of a
factors of b
common factors of a and b
and the range for finding of lcm of an array of numbers
Justin Walters
@FFX01
Jun 27 2015 18:49
but isn't the gcf for all the ranges 1?
Nic Galluzzo
@ngalluzzo
Jun 27 2015 18:50
anyone got any tips for symmetric difference?
Lightwaves
@Lightwaves
Jun 27 2015 18:51
differs what the range of numbers is
[2,4,6,8,10]
the gcf for this range is 2
because 2 is the number that can divide evenly into all numbers in this range
the only other number is 1
but 2 is bigger then 1 hence the greatest common factor
Justin Walters
@FFX01
Jun 27 2015 18:53
i see that, but all the ranges in the exercise for lcm begin with 1
Lightwaves
@Lightwaves
Jun 27 2015 18:53
leact common multiple is different it's the largest number that all these numbers can divide into
John Ellis
@johnmellis
Jun 27 2015 18:54
has anyone here successfully created a pull request and pushed to master on FCC?
Justin Walters
@FFX01
Jun 27 2015 18:54
yeah, but supposedly theres a way to use gcf to fin lcm
John Ellis
@johnmellis
Jun 27 2015 18:54
I need a quick walkthrough of how to do it - I have my local environment up
Lightwaves
@Lightwaves
Jun 27 2015 18:54
oh the algorithmn for that is a*b / gcf(a, b)
Suzanne Atkinson
@AdventureBear
Jun 27 2015 18:54
@johnmellis not yet. maybe try to pair with quincy, nathan or @BerkeleyTrue
Lightwaves
@Lightwaves
Jun 27 2015 18:54
I used that to find the lcm
Justin Walters
@FFX01
Jun 27 2015 18:55
thanks. I'll try it.
Lightwaves
@Lightwaves
Jun 27 2015 18:56
slight modification
@FFX01
The exact algorithm is
Math.abs(a*b)/gcf(a,b)
Logan Tegman
@ltegman
Jun 27 2015 19:19
@johnmellis I think generally PRs directly to master are frowned up. Staging is the preferred branch for PRs.
sowpat
@sowpat
Jun 27 2015 19:37

Can anyone explain to me where I went wrong in my code for the Pairwise bonfire?: ```function pairwise(arr, arg) {
var indices = [];
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr.length; j++){
if (arr[i] + arr[j]===arg){
if (arr[i] !== arr[j]){
indices.push(i);
indices.push(j);
arr.splice(i, 1);
arr.splice(j, 1);
}
else{
indices.push(i);
arr.splice(i, 1);
}
}
}
}
var answer = indices.reduce(function(a, b){
return a + b;
});
return answer;
}

pairwise([1,4,2,3,0,5], 7);

blob
There's a better image of it, it enlarges when you click on it
John Ellis
@johnmellis
Jun 27 2015 19:40
@itegman got it, thanks
sowpat
@sowpat
Jun 27 2015 20:11
Can anyone help me with pairwise? My code is the image above
ronaldrdguez
@ronaldrdguez
Jun 27 2015 20:26
@sowpat I see a problem with the calls to splice. Once you do the first one, j will no longer point to the element you want to remove. I added some log statements to your code, run it and see.
function pairwise(arr, arg) {
  var indices = [];

  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr.length; j++){
      if (arr[i] + arr[j]===arg){
        if (arr[i] !== arr[j]){
          console.log('arr=', arr);
          console.log('i=', i, 'j=', j);
          indices.push(i);
          indices.push(j);
          arr.splice(i, 1);
          console.log('arr=', arr);
          arr.splice(j, 1);
          console.log('arr=', arr);
          //console.log('inside if...');
          //console.log('indices=', indices);
          //console.log('arr =', arr);
        }
        else {
          indices.push(i);
          arr.splice(i, 1);
        }
      }
    }
  }

  var answer = indices.reduce(function(a, b){
    return a + b;
  });

  return answer;
}

var result = pairwise([1,4,2,3,0,5], 7);

console.log(result);
sowpat
@sowpat
Jun 27 2015 20:29
@ronaldrdguez Ohhhhh, yeah I see where I messed up. Thank you so much for the help :)
ronaldrdguez
@ronaldrdguez
Jun 27 2015 20:30
no problem
David Wilbanks
@dwilbank68
Jun 27 2015 20:34
anyone got some insight on the npm tutorial?
Freddy
@Lemony-Andrew
Jun 27 2015 20:49
Anyone here know node decently?
Candis Wasell
@CandiW
Jun 27 2015 21:01
Hi - is there anyone who had done the Truncate a String Bonfire? I'm a bit stuck....
here's the code:
function truncate(str, num) {
  // Clear out that junk in your trunk
  if (num > 0){
    return str.slice(0,8) + '...';
  }
  return str;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
its returning the string 'A-tisket...' properly but there's two other errors 'should not truncate if string is = length' and 'should not truncate if string is < length: expected 'A-tisket...' to equal 'A-tisket a-tasket A green and yellow basket'
David Wilbanks
@dwilbank68
Jun 27 2015 21:04
if (num > 0) needs to be tailored
Candis Wasell
@CandiW
Jun 27 2015 21:04
ok - that's what I suspected...
David Wilbanks
@dwilbank68
Jun 27 2015 21:05
you aren't checking the length of str
and using that length anywhere...
Candis Wasell
@CandiW
Jun 27 2015 21:07
thanks for the help - silly mistake for me :)
David Wilbanks
@dwilbank68
Jun 27 2015 21:07
yay
Jeff Berman
@JeffUberman
Jun 27 2015 21:08
anyone able to give a little guidance on 'where art thou?'
````
function where(collection, source) {
  var arr = [];
  for(var i = 0; i < collection.length; i++){
    for(var item in collection[i]){
      if(source.hasOwnProperty(item)){
        arr.push(collection[i]);
      }
    }

  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Candis Wasell
@CandiW
Jun 27 2015 21:10
I've done the npm tutorial - i can try to help?
Moisés Man
@moigithub
Jun 27 2015 21:10
@JeffUberman where have 2 arguments
1 array of Objects
and 2.. an object
@JeffUberman u need to return the object from first array.. who have the same attribute/value as second argument
Jeff Berman
@JeffUberman
Jun 27 2015 21:11
@moigithub right, so I iterate initially over the array, and for each index I check if it has the property in the source arguement
I guess I'm having trouble testing for property value
without using the actual name of the property (source.last)
Joe Balsamo
@Joe-Balsamo
Jun 27 2015 21:14
Anyone in this room know what the status on the html convert bonfire is? I’m assuming it is still not working correctly?
Candis Wasell
@CandiW
Jun 27 2015 21:15
No - sorry, I'm not there yet
Moisés Man
@moigithub
Jun 27 2015 21:16
@JeffUberman acording to that example.. it should return { first: 'Tybalt', last: 'Capulet' }].... cuz its the only object in the array.. who have the key "last" with value "Capulet"
Joe Balsamo
@Joe-Balsamo
Jun 27 2015 21:17
@CandiW thanks, I’m pretty sure it is because it look slike the assert isn’t set up right, plus I’m pretty sure I have it working.
Candis Wasell
@CandiW
Jun 27 2015 21:18
Bummer - you could report the bug on GitHub and I'm sure FCC will get on it...
Jeff Berman
@JeffUberman
Jun 27 2015 21:18
@moigithub it actually returns every item in the array that has the property 'last', so all of them
Joe Balsamo
@Joe-Balsamo
Jun 27 2015 21:20
@CandiW I think it’s a pretty well known issue, just was asking in case they fixed it and I screwed up ;)
Candis Wasell
@CandiW
Jun 27 2015 21:20
ok - no problem
Moisés Man
@moigithub
Jun 27 2015 21:21
@JeffUberman at left side of the bonfire click the button MORE INFORmation.. n check those some helpful links:
u need to check if the VALUE of the object attribute === argument VALUE of the same attribute (Capulet in this case)
Joe Balsamo
@Joe-Balsamo
Jun 27 2015 21:21
In fact, @QuincyLarson was talking about that they DID fix it, but hasn’t been rolled in yet. Just my OCD and all… :)
I’ll just try it again tomorrow
Jeff Berman
@JeffUberman
Jun 27 2015 21:22
@moigithub I'll take a look- thanks!
Jeff Berman
@JeffUberman
Jun 27 2015 21:42
@moigithub ````
````
function where(collection, source) {
  var arr = [];
  var testArr = Object.keys(source);
  for(var i = 0; i < collection.length; i++){
    for(var item in collection[i]){
      if(collection[i][item] == source[testArr]){
        arr.push(collection[i]);
      }
    }

  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
is this what they had in mind? it passes the test, but I can't shake the feeling it's not a great way of doing this
Nick Magerko
@nmagerko
Jun 27 2015 21:45

Hey guys, question on the “Symmetric Difference” bonfire. To begin, here’s my solution (code review comments certainly welcome):

function sym(args) {
  args = Array.prototype.slice.call(arguments);
  if(args.length == 1) {
    args.push([]);
  }

  return args.reduce(function(prev, curr) {
    var larger, smaller;
    var difference = [];
    var matching = [];

    if(prev.length > curr.length) {
      larger = prev;
      smaller = curr;
    }
    else {
      larger = curr;
      smaller = prev;
    }

    larger.forEach(function(element){
      if(matching.indexOf(element) >= 0) return;
      if(smaller.indexOf(element) >= 0) return matching.push(element);
      if(difference.indexOf(element) < 0) return difference.push(element);
    });


    smaller.forEach(function(element){
      if(matching.indexOf(element) < 0 && difference.indexOf(element) < 0) difference.push(element);
    });

    return difference;
  });
}

My output for each test case is technically correct. However, it’s out of order from what the tester is expecting. For example, my method outputs [ 5, 4, 3 ] in the first test case, but [ 3, 5, 4 ] is expected. Does order matter in symmetric difference?

ronaldrdguez
@ronaldrdguez
Jun 27 2015 21:52
@nmagerko Technically no, order shouldn’t matter, the tests, however, are comparing arrays, not sets. Seems you’re expected to traverse top-bottom/left-right while adding to difference. I too had to modify my code to make it work.
Mushfiq Khalid
@mushfick
Jun 27 2015 21:53
]=\7
Nick Magerko
@nmagerko
Jun 27 2015 21:53
Hmmm fair enough
Code review still stands for anyone btw :P
ronaldrdguez
@ronaldrdguez
Jun 27 2015 21:58
@nmagerko why the length-swap at the top?
Nick Magerko
@nmagerko
Jun 27 2015 22:08
Mmm you know what, there is no reason for that
I just took it out
(And guess what, the tests passed)
So thank you a ton :P
Jeff Berman
@JeffUberman
Jun 27 2015 22:12
can anyone help me understand .filter() method a bit better?
function destroyer(arr) {
  var destroyedArr = arr.filter(function(){
    for(var i = 0; i<arguments.length; i++){
      for(var j = 0; j<arr.length; j++){
        if(arguments[i] === arr[j]){
          arr.slice(j, j+1);
        }
      }
    }
  });
  return destroyedArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
my 'Seek and Destroy' is returning a blank array
Spatz
@Spatzerny
Jun 27 2015 22:13
mine keeps telling me that filter is not a function :F
ronaldrdguez
@ronaldrdguez
Jun 27 2015 22:13
@nmagerko glad it helped :P
Mike Semko
@MadOgre
Jun 27 2015 22:13
@JeffUberman I can
Suzanne Atkinson
@AdventureBear
Jun 27 2015 22:14
You're rewriting the loop on filter when filter will do it for you
Spatz
@Spatzerny
Jun 27 2015 22:14
@JeffUberman function has toReturn true to keep the element, false otherwise.
Mike Semko
@MadOgre
Jun 27 2015 22:14
filter method is one of many methods in JavaScript that involved callbacks
The function passed to filter method needs to have 3 parameters in specific order
Although 2 last ones may be omitted
The parameters are value, index, and array
Suzanne Atkinson
@AdventureBear
Jun 27 2015 22:15
Filter needs to know what to iterate over in the function argument and you're not passing it anything
Mike Semko
@MadOgre
Jun 27 2015 22:16
The first parameter (value) passes the current value in each position
second parameter is for the index so it gets 0, 1, 2, 3... etc
and the third parameter is the array itself in case you need to modify it somehow
Jeff Berman
@JeffUberman
Jun 27 2015 22:16
so arr.filter(function(arr){code});
Moisés Man
@moigithub
Jun 27 2015 22:16
[1,2,3,4,5].filter(function(value){return value>3 ; } );
Mike Semko
@MadOgre
Jun 27 2015 22:17
@JeffUberman yes except first parameter is not array its value
Then you can test the value inside the function and return true or false accordingly
For instance @moigithub 's example will return array [4, 5] because only 4 and 5 are bigger than 3
ronaldrdguez
@ronaldrdguez
Jun 27 2015 22:18
@JeffUberman Check http://jhusain.github.io/learnrx/ exercises 6 and 7. These will tell you exactly what filter is all about.
Suzanne Atkinson
@AdventureBear
Jun 27 2015 22:19
@JeffUberman Jeffuberman pass an "item" into the function Param, not the arr again. The callback will execute once for each "item"
Mike Semko
@MadOgre
Jun 27 2015 22:19
Here is what my code looks like for that assignment
function destroyer(arr) {
  var args = arguments;
  arr = arr.filter(function(value){
    for (var i = 1; i < args.length; ++i) {
      if (value == args[i]) {
        return false;
      }
    }
    return true;
  });
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Pay special attention to the line var args = arguments;
Moisés Man
@moigithub
Jun 27 2015 22:20
or like this
function isGreaterThan3(value) {
if (value>3) return true;
return false

}

[1,2,3,4,5].filter(isGreaterThan3);
Mike Semko
@MadOgre
Jun 27 2015 22:23
If you use arguments inside the callback function arguments will contain the arguments of the callback function and not of destroyer
Jeff Berman
@JeffUberman
Jun 27 2015 22:23
ahhh, okay i think i'm starting to get it
Jeff Berman
@JeffUberman
Jun 27 2015 22:30
thanks @MadOgre, @moigithub , and @AdventureBear
and @Spatzerny & @ronaldrdguez
Mike Semko
@MadOgre
Jun 27 2015 22:31
@JeffUberman You're welcome
Moisés Man
@moigithub
Jun 27 2015 22:33
var args = [].slice.call(arguments);        <-- will be [[1,2,3,1,2,3]  , 2 , 3]

if u wanna skip first argument u can
var args = [].slice.call(arguments).slice(1); <-- will be [2,3]

then u can use indexOf on ur filter

return args.indexOf(value)===-1
Rasheed Bustamam
@abustamam
Jun 27 2015 22:49
Can someone give me some direction on arguments optional?
I'm having trouble returning a function
Mike Semko
@MadOgre
Jun 27 2015 22:50
@abustamam may I see your code
Rasheed Bustamam
@abustamam
Jun 27 2015 22:51
I have the 2 args and the non-number args, so i'll just give you what i have for the 1 arg:

    var func = new Function ('arg', 'return arg');
    return func;
wait
let me try something
Mike Semko
@MadOgre
Jun 27 2015 22:51
function should be lowecase
Rasheed Bustamam
@abustamam
Jun 27 2015 22:52
it yells at me if its lowercase
i thought we use uppercase since we're using constructor notation
Mike Semko
@MadOgre
Jun 27 2015 22:52
I am not sure what context this is for
you said you are trying to return a function
Rasheed Bustamam
@abustamam
Jun 27 2015 22:53
yeah i can return a function
but it wont do what i want it to do
Mike Semko
@MadOgre
Jun 27 2015 22:53
I can help you but I need to see more code to understand what you are trying to achieve
Rasheed Bustamam
@abustamam
Jun 27 2015 22:53
function add() {
  var args = Array.prototype.slice.call(arguments);

  if (!args.every(function(o){
    return typeof(o) == "number";
  })){
    return undefined;
  }

  if (args.length == 1) {
    var sumAAnd = add(args[0]);

    var func = new Function ('arg', 'return add(2)');
    return func;
  }

  return args[0] + args[1];


  //return false;
}

add(2,3);
thats the whole code
Mike Semko
@MadOgre
Jun 27 2015 22:54
Is this a bonfire ?
Rasheed Bustamam
@abustamam
Jun 27 2015 22:54
yes
the last beginner bonfire
the problem i'm running into is passing in args[0] into the returned fucntion, since it has a different scope
Mike Semko
@MadOgre
Jun 27 2015 22:56
there is no need to use constructor notation here
Rasheed Bustamam
@abustamam
Jun 27 2015 22:56
lemme try without using constructor notation
i only used it b/c it was in a helpful link and i hadn't used it before
ok it worked just using var func = function()...
Mike Semko
@MadOgre
Jun 27 2015 22:58
you want your function return statement to look similar to this
      return function(num) {
        if (typeof num == "number") {
           return num + args[0];
        } else {
          return undefined;
        }
you don't even need the func variable
Rasheed Bustamam
@abustamam
Jun 27 2015 22:58
yeah thats how mine looked like
i just used func as a placeholder
Mike Semko
@MadOgre
Jun 27 2015 22:59
There you go that should work
Rasheed Bustamam
@abustamam
Jun 27 2015 22:59
it did, thanks!
Nick Magerko
@nmagerko
Jun 27 2015 23:31

Not sure I understand the directions on the “Inventory Update” bonfire… as I understand it, if (essentially) there’s an item in the second array that existed in the first array, we use the item count from the second array to replace that of the first. However, in this test

assert.deepEqual(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]), [[88, 'Bowling Ball'], [2, 'Dirty Sock'], [3, 'Hair Pin'], [3, 'Half-Eaten Apple'], [5, 'Microphone'], [7, 'Toothpaste']]);

That is not true. Indeed, the ‘Bowling Ball’ inventory is being compounded, not updated.

Did anyone else have this issue?
Sophanarith Sok
@sok213
Jun 27 2015 23:45
I need help. I'm not sure what to do on Bonfire: Convert HTML Entities. I was told that the tests for this exercise is not working properly. I have written code that converts the symbols to the corresponding Html entity, but it still won't pass. Can someone explain what the results should be.
Mike Semko
@MadOgre
Jun 27 2015 23:47
@sok213 You are correct this exercise is bugged. Apparently they already fixed it but have not made the changed live yet. The second test does not pass.
Sophanarith Sok
@sok213
Jun 27 2015 23:47
function convert(str) {
  // &colon;&rpar;
  var string = str.split('');
  var result = [];

  string.filter(function(word) {
     if(word == '&') {
         result.push('&amp');
     } else if(word == '<') {
         result.push('&lt');
     } else if(word == '>') {
         result.push('&gt');
     } else if(word == "\'") {
         result.push('&apos');
     } else if(word == '\"') {
         result.push('&quot');
     } else if(word == ' ') {
         result.push(' ');
     } else {
         result.push(word);
     }
  });

  result = result.join('');
  return(result);
}


convert('Dolce & Gabbana');
That is the code that I have came up with
Mike Semko
@MadOgre
Jun 27 2015 23:48
You forgot the semicolons
'&amp;' etc
otherwise it's correct
Tests 1 and 3 should pass but the second test always fails
until the bug is fixed
Sophanarith Sok
@sok213
Jun 27 2015 23:49
the '&amp' is at the top of the if statement, isnt it?
Mike Semko
@MadOgre
Jun 27 2015 23:50
the semicolon is not part of javascript
it should be part of the HTML entity
Adam Rehard
@adamrehard
Jun 27 2015 23:50
```
Mike Semko
@MadOgre
Jun 27 2015 23:50
inside the quotes
Like this
  string.filter(function(word) {
     if(word == '&') {
         result.push('&amp;');
     } else if(word == '<') {
         result.push('&lt;');
     } else if(word == '>') {
         result.push('&gt;');
     } else if(word == "\'") {
         result.push('&apos;');
     } else if(word == '\"') {
         result.push('&quot;');
     } else if(word == ' ') {
         result.push(' ');
     } else {
         result.push(word);
     }
  });
Sophanarith Sok
@sok213
Jun 27 2015 23:53
@MadOgre OHHH!! Wow, I totally didn't notice that! Thanks you
Adam Rehard
@adamrehard
Jun 27 2015 23:53
I'm doing JS waypoint 2, and ran into a bit of trouble on Codecademy. Anybody see anything I missed? Error being thrown is "unexpected token {"
var userChoice = prompt("Do you choose rock, paper or scissors?")

var computerChoice = Math.random()

console.log(computerChoice);

if (computerChoice < 0.33) {
    computerChoice = "rock";
} else if (computerChoice > 0.34 && computerChoice < 0.66) {
    computerChoice = "paper";
} else (computerChoice > 0.67) {
    computerChoice = "scissors";
}
David Wilbanks
@dwilbank68
Jun 27 2015 23:54
I see second line is not terminated. That can cause such errors.
Mike Semko
@MadOgre
Jun 27 2015 23:54
no, that's not it
that last else has no if but has a condition
so either insert an if or remove the condition altogether
because if its not the first one and not the second one, the only thing left is the third one
Adam Rehard
@adamrehard
Jun 27 2015 23:55
That'd be it. I'm an idiot. Thanks!
Sophanarith Sok
@sok213
Jun 27 2015 23:56
@MadOgre For Bonfire: Convert HTML Entities. If the test i bugged, does that mean my code still won't pass even if it is correct?
is*
Mike Semko
@MadOgre
Jun 27 2015 23:57
The second test will fail but the other two will pass
Steven Leiva
@StevenXL
Jun 27 2015 23:57
Can someone help me out on the TwitchTV API zipline?
Mike Semko
@MadOgre
Jun 27 2015 23:57
@StevenXL Sorry I haven't got to that one yet
David Wilbanks
@dwilbank68
Jun 27 2015 23:58
how? interface or API?
Steven Leiva
@StevenXL
Jun 27 2015 23:59
@dwilbank68 I can confirm (through console.log) that I am getting the data from the API, but once I have it I want to parse it (create a simply object for only the data that I need), and then add that object to an array.
But I am getting an empty array.
David Wilbanks
@dwilbank68
Jun 27 2015 23:59
and you are attempting this parse INSIDE the callback function?