22nd
Jun 2015
Steven Leiva
@StevenXL
Jun 22 2015 00:07
@tourn171 Can you show me what the results should be when you call:
Brett Flanders
@tourn171
Jun 22 2015 00:10
@StevenXL depends on the amount of change could be [['Quarter', 0.50]] [['TEN', 20.00],['FIVE', 5.00]] 'Insuffient Funds' 'Closed'
@StevenXL also should point out the only reason this is easy for me is i kinda had to do a C version of this for Harvards CS50X
@StevenXL this one is a little more complex than that one but basically the same things
Freddy
@Lemony-Andrew
Jun 22 2015 00:12
I've been having quite a bit of trouble with users getting 503 errors on my zipline , can someone check and see if it's working for them? The problem is basically this: Once the user clicks "quote me" the quotes don't load.
The zipline is here: http://lemonfinity.com/extra/portfolio/quotemachine.html
Alfonso Balsera Martinez
@AlfonB6
Jun 22 2015 00:24
hello guys! what would you have to build that is to the standard of 1)entry level web dev 2) Junior dev
Brett Flanders
@tourn171
Jun 22 2015 00:25
@Lemony-Andrew seeing as the rest of your website is working if your getting 503 errors you might want to make sure that your connecting to the right server
Alfonso Balsera Martinez
@AlfonB6
Jun 22 2015 00:26
David Wilbanks
@dwilbank68
Jun 22 2015 00:34
@tourn171 ahaha same here
@tourn171 did you finish the CS50?
Brett Flanders
@tourn171
Jun 22 2015 00:42
@dwilbank68 no last year i could run the appliance but it was on a borrowed laptop so i never got to finish this year i have my own laptop but since they updated the appliance i cant run it (my laptop doesn't have 64 bit windows even though the hardware can run it)
David Wilbanks
@dwilbank68
Jun 22 2015 00:45
I stopped and turned to javascript about halfway through... right about the time when we were supposed to devise a hashing method to evenly distribute many many thousands of objects (I forgot the details), into 26 arrays (I think?) based on the first letter of their name.
never did go back and find that hashing algorithm
Lightwaves
@Lightwaves
Jun 22 2015 00:52
That actually sounds somewhat practical
David Wilbanks
@dwilbank68
Jun 22 2015 00:55
maybe it was to create a trie structure
This message was deleted
so any JSONP experts here?
Freddy
@Lemony-Andrew
Jun 22 2015 01:05
@tourn171 Hey Bret, I don't think that's the reason. It doesn't make sense to me that it works for some people but doesn't for others. All I'm doing is a query search through yahoo's API and sometimes it responds with the errors
@dwilbank68 What's up with jsonp?
All it really is passing the returned json structure inside of a function defined in the callback of the url
the AJAX function for JQUER can handle the paramaters there
David Wilbanks
@dwilbank68
Jun 22 2015 01:07
I'm just doing a query without it, and I'm getting results. Wondering why others are using the '&callback=' business?
sometimes they use '&callback=?' which is no function at all, and thus I get confused
Freddy
@Lemony-Andrew
Jun 22 2015 01:08
I believe it depends on what the sites server likes to respond to.
David Wilbanks
@dwilbank68
Jun 22 2015 01:08
have you done the wikipedia api?
Freddy
@Lemony-Andrew
Jun 22 2015 01:08
If it understands JSONP requests it will send a jsonp response.
@dwilbank68 I'm stuck on zipline # 2 because of 503 errors..
David Wilbanks
@dwilbank68
Jun 22 2015 01:09
I will look and see how I got around that
twitch.tv?
Freddy
@Lemony-Andrew
Jun 22 2015 01:11
Random quote machine
Can you tell me if it works for you? If it's getting a large amount of 503 responses it should display a loading image
David Wilbanks
@dwilbank68
Jun 22 2015 01:12
worked just fine
speedy enough
Freddy
@Lemony-Andrew
Jun 22 2015 01:13
It's weird that it works for some but not for others
It's either hit or miss
David Wilbanks
@dwilbank68
Jun 22 2015 01:13
me chrome on osx, if you're keeping statistics
Freddy
@Lemony-Andrew
Jun 22 2015 01:14
It's completely random as far as I know. It's works for me on Chrome on windows, but another guy with the same situation it doesn't. Yours work, and you're on a different os
It's really weird
David Wilbanks
@dwilbank68
Jun 22 2015 01:15
blame the server I guess
Freddy
@Lemony-Andrew
Jun 22 2015 01:15
By the way, what are you having problems with on your wikipedia api?
David Wilbanks
@dwilbank68
Jun 22 2015 01:15
Steven Leiva
@StevenXL
Jun 22 2015 01:33
@tourn171 I think I officially have the ugliest solution to Exact Change bonfire.
But I solved it.
Definitely didn't create an object.
Lightwaves
@Lightwaves
Jun 22 2015 01:43
I think I spilt one answer to the sum the primes bonfire but I wouldn't even use it because it's practically cheating.
Pretty much you learn nothing but a weird math fact
jaytealong
@jaytealong
Jun 22 2015 01:44
I'm having a challenge very early on, would someone be able to assist? For some reason, I'm having trouble getting the image width property to apply to an image using the style. When I type "width=100px" into the image tag, it works, but not when I write in 'class='smaller-image''
Lightwaves
@Lightwaves
Jun 22 2015 01:45
was that written exactly?
jaytealong
@jaytealong
Jun 22 2015 01:46
Just a second

<style>
.red-text {
color: red;
}
.smaller-image { width=100px;}
h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}
</style>

<h2 class='red-text'>CatPhotoApp</h2>

<img class='smaller-image' src='https://bit.ly/fcc-kittens'/>

<p class='red-text'>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>
<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Lightwaves
@Lightwaves
Jun 22 2015 01:49
hmm thats odd
it seems right I can't make out something you missed hold on.
Alyssa Alvarez
@AlysCole
Jun 22 2015 01:50
@jaytealong In the class .smaller-image change width=100px; to width: 100px;
jaytealong
@jaytealong
Jun 22 2015 01:51
holy canoli, thanks so much
Lightwaves
@Lightwaves
Jun 22 2015 01:51
yeah I missed that
jaytealong
@jaytealong
Jun 22 2015 01:51
I can't believe I didn't notice, but there you go
Lightwaves
@Lightwaves
Jun 22 2015 01:51
haha I didn't notice either
Alyssa Alvarez
@AlysCole
Jun 22 2015 01:52
It's easy to overlook symbols. xD I do it all the time.
Alem
@alemneh
Jun 22 2015 02:12
This message was deleted
Alem
@alemneh
Jun 22 2015 02:20
Can someone tell me why the fromCharCode() is not printing
function fearNotLetter(str) {
var alp = "abcdefghijklmnopqrstuvwxyz";

console.log(alp.charCodeAt(4));
console.log(alp.fromCharCode(100));
return str;
}

fearNotLetter('abce');
Nicholas Butterworth
@Nbutter
Jun 22 2015 02:21
@alemneh fromCharCode() is a property of the global String object. it's probably not a property of alp. what did you expect it to print?
Suzanne Atkinson
Jun 22 2015 02:38
String.fromCharCode(101)
Alem
@alemneh
Jun 22 2015 02:42
@AdventureBear @Nbutter Thanks guys i changed it to String.fromCharCode()
Jun 22 2015 03:26
Jj
William
@minimalistStig
Jun 22 2015 03:31
Can someone help me with the bonfire: Map the debris? I have no idea how to start
ronaldrdguez
@ronaldrdguez
Jun 22 2015 04:42
@minimalistStig You get the orbital period using $2\pi\sqrt{ (r + h)^3/\mu }$ (from the wiki article), the axis length is the distance between the central body (Earth) and whatever object is orbiting. This length equals to the Earth radius (r) + avgAlt (h). Hope this helps.
William
@minimalistStig
Jun 22 2015 04:46
@ronaldrdguez thanks! I got it now! thanks again!
ronaldrdguez
@ronaldrdguez
Jun 22 2015 04:48
@minimalistStig np
silvanatsp
@silvanatsp
Jun 22 2015 04:59
hey . i am stuck with the width attribute on the kitty image, which is the correct order to write it?

i have it in this way
</style>

<style> .smaller-image { width: 100 px;}
</style>

<h2 class='red-text'>CatPhotoApp</h2>

<img src='https://bit.ly/fcc-kittens'/>

ronaldrdguez
@ronaldrdguez
Jun 22 2015 05:06
@silvanatsp you didn't apply it to <img> tag I think
Luis Fuentes
@luis-fuentes
Jun 22 2015 05:07
<img class='smaller-image' src='https://bit.ly/fcc-kittens'/> you need to give the class to the img
Matthew Vogel
@matthewsvm
Jun 22 2015 05:08
Has anyone done the "smallest common multiples” bonfire yet? I’m kind of having difficulty understanding what it is even asking.

Find the smallest number that is evenly divisible by all numbers in the provided range.

The range will be an array of two numbers that will not necessarily be in numerical order.

silvanatsp
@silvanatsp
Jun 22 2015 05:09
@YotaCL and after givin it the class i create the style and width attribute in that same line?
Matthew Vogel
@matthewsvm
Jun 22 2015 05:13
does “range” mean all numbers between the two or just those two numbers?
Luis Fuentes
@luis-fuentes
Jun 22 2015 05:13
@silvanatsp yes. you give all the attributes inside the {}
ronaldrdguez
@ronaldrdguez
Jun 22 2015 05:13
@matthewsvm You get a 2-element array as input, lets say [5,2], it means you need to find the least common multiple of 5,4,3,2
Matthew Vogel
@matthewsvm
Jun 22 2015 05:14
ok, @ronaldrdguez that’s what I was afraid of
Shaila Gray
@sgrayme
Jun 22 2015 05:31
is there a list of the FCC 'channels' (on Gitter) somewhere?
Luis Fuentes
@luis-fuentes
Jun 22 2015 05:35
Waqar Hocain
@waqarHocain
Jun 22 2015 05:36
@YotaCL it doesn't shows the channel list
anyone here on "Make a Person" bonfire?
Luis Fuentes
@luis-fuentes
Jun 22 2015 05:38
work for me yesterday, but maybe they made changes, you can search too
Matthew Vogel
@matthewsvm
Jun 22 2015 05:47
Anyone want to throw me some hints on the common multiples one?
Matthew Vogel
@matthewsvm
Jun 22 2015 05:53

This is what I’ve done so far:
function smallestCommons(arr) { arr = arr.sort(); var holder = []; // if some number is divisible by arr[0] && arr[1]...&&...arr[last] // return it // find the factors; for the factor that happens the most // in any number, multiply them together. // i.e. 6, 9, 27 // 2 * 3, 3 * 3, 3 * 3 * 3 // so the answer is 2 * 3 * 3 * 3 = 54 var summit = arr[0]; var someIt = arr[1]; for(i = summit; i <= someIt; i++) { holder.push(i); }

return holder;
}

smallestCommons([99, 87]);

Akira Laine
@AkiraLaine
Jun 22 2015 05:53
isn't it suppose to be var somelt = arr1
oh. nvm
Matthew Vogel
@matthewsvm
Jun 22 2015 05:55
oh, that was just some talking to myself commenting stuff
also, how come all that didn’t turn to code?
Akira Laine
@AkiraLaine
Jun 22 2015 05:56
console.log("Test");
console.log("Test");
@matthewsvm not sure
Sam Crowe
@crowesam
Jun 22 2015 05:59
I've tried to go back
Jeff Wilkey
@JeffWilkey
Jun 22 2015 06:11
@matthewsvm Try putting the three backticks on the line above your code and the line below your code
If your three backticks are not spaced from your code I think markdown will read all that as one line
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 06:23
This message was deleted
Suzanne Atkinson
Jun 22 2015 06:38
@waqarHocain still need help with make a person?
Terrell Vest
@MirPresT
Jun 22 2015 06:49
hey anyone have experience with the pig latin bonfire?
Waqar Hocain
@waqarHocain
Jun 22 2015 06:57
Suzanne Atkinson
Jun 22 2015 07:09
what have you done so far/
rwickline11
@rwickline11
Jun 22 2015 07:32
hey ran out of ideas for the chunky monkey bonfire (splitting a array (1st arg) into chunks determined by the 2nd arg and then returned as a multidimensional array). any help appreciated
Waqar Hocain
@waqarHocain
Jun 22 2015 07:35
rwickline11
@rwickline11
Jun 22 2015 07:37
well now I don't really have much. I've gone through a couple of different things that just haven't been working out, but what I was working with here is kind of half an idea

function chunk(arr, size) {
// Break it up.
var newArr = [];
for(i=0;i<size;i++){
var subArr = new Array(size);
newArr.push(subArr);
for(j=0;j<arr.length;j++){
newArr[i][j] = arr[j];
}
}
return newArr;
}

chunk(['a', 'b', 'c', 'd'], 2);

function chunk(arr, size) {
// Break it up.
var newArr = [];
for(i=0;i<size;i++){
var subArr = new Array(size);
newArr.push(subArr);
for(j=0;j<arr.length;j++){
newArr[i][j] = arr[j];
}
}
return newArr;
}

chunk(['a', 'b', 'c', 'd'], 2);

sorry about the formatting thing. I forget how to put the code in the box
but what I was imagining conceptually was looping through each sub array using a for loop and then within that loop using another for loop to put each individual element inside each sub array
Jeff Wilkey
@JeffWilkey
Jun 22 2015 08:08
@rwickline11 put your three backticks above the first line of your code and below the last line of your code
rwickline11
@rwickline11
Jun 22 2015 08:08
coolness thanks
Jeff Wilkey
@JeffWilkey
Jun 22 2015 08:09
@rwickline11 no problem
Cristalin Solis
@Neebulo
Jun 22 2015 08:31
any chance someone can help with translating these verbals into a javascript expression? http://repl.it/t9j
ar2g
@ar2g
Jun 22 2015 08:59
@Neebulo Which one do you need help with?
Cristalin Solis
@Neebulo
Jun 22 2015 09:22
@ar2g, I figured the hotOrNot function, but the rest, I cant seem to translate it the right way or i have no clue
ar2g
@ar2g
Jun 22 2015 09:45
@Neebulo so if you ask me a specific question I'll happily help
ar2g
@ar2g
Jun 22 2015 10:10
@Chhavi24 Yeah I saw that - is there a hover property for the data point you could use to display the matrix?
@Chhavi24 it's not clear how the matrix data is related to the chart data
Chhavi24
@Chhavi24
Jun 22 2015 10:32
@ar2g the data points i.e False Positive rate and True Positive rate is calculated from a matrix like http://www.mdpi.com/sensors/sensors-14-00848/article_deploy/html/images/sensors-14-00848f6-1024.png
Bianca Mihai
@biancamihai
Jun 22 2015 10:36
@Chhavi24 if the documentation does not present this feature you can 1. extend the library that you use now to do what you need, 2. look for another library to represent your graph (one that allows you to display on click something custom), take a look at http://nvd3.org/ (I used it in my projects on statistics - don’t know if is what you need)
Chhavi24
@Chhavi24
Jun 22 2015 10:39
@biancamihai Thanks a lot but my basic problem is : If I can find a way to update the contents of a table (4 by 4) as the user clicks on the data point
Bianca Mihai
@biancamihai
Jun 22 2015 10:40
perhaps you can with some jquery on click events … depending on the dom...
Bianca Mihai
@biancamihai
Jun 22 2015 10:45
so my suggestion will not work :)
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:46
function largestOfFour(array)
{
var b=0;
var max = [];
for(i = 0 ; i < array.length; i++){
b += array[i].length;
}
for (i = 0 ; i < b; i++)
{
max1 = Math.max(array[i]);
max.push(max1);
}
console.log(b);
return max;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Can someone help?
I need to get max from each array and create an array of maxs.
ar2g
@ar2g
Jun 22 2015 10:48
I'm not familiar with this library at all, but this might be a useful bit of documentation @Chhavi24 : https://developers.google.com/chart/interactive/docs/basic_interactivity
Bianca Mihai
@biancamihai
Jun 22 2015 10:48
I did work on a progect with svg doing some manipulation, searching now to see if it might help you ...
project
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:49
@biancamihai poti sa ma ajuti?
Salut
Bianca Mihai
@biancamihai
Jun 22 2015 10:50
hei @copywithpaste :) k, looking now
what is the problem?
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:50
Imi da null, de 16 ori
ar2g
@ar2g
Jun 22 2015 10:50
@copywithpaste the second for loop - what's it doing?
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:51
for maximum number from each sub-array
Bianca Mihai
@biancamihai
Jun 22 2015 10:51
@copywithpaste array[i] is an array right?
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:51
yep
Bianca Mihai
@biancamihai
Jun 22 2015 10:52
typethis in your console Math.max([6, 4, 3]); >>>> Nan
then try this :) Math.max.apply(Math,[6, 4, 3]); >>>> 6
Christian Petersen
@fnky
Jun 22 2015 10:53
because [6, 4, 3] isn't a number, use Math.max.apply(Math, [6, 4, 3]) :-)
Bianca Mihai
@biancamihai
Jun 22 2015 10:53
and you don’t need 2 loops ;)
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:54
but I can't use array[i], in place of [6, 4,...] ?
Christian Petersen
@fnky
Jun 22 2015 10:55
array[i] selects a specific value in array where i is the index to select
Bianca Mihai
@biancamihai
Jun 22 2015 10:55
yes use a variable, I just gave you an example :P
but you can write this in 2 lines of code
no need for the for loops
ar2g
@ar2g
Jun 22 2015 10:56
I did this with 2 nested for loops and without using max
Bianca Mihai
@biancamihai
Jun 22 2015 10:56
what bonfire is this? I want to test my 2 lines solution :P
Christian Petersen
@fnky
Jun 22 2015 10:56
If I can avoid using nested loops, I'll do that
Bianca Mihai
@biancamihai
Jun 22 2015 10:57
when I solved it it was not so slick :D
ar2g
@ar2g
Jun 22 2015 10:57
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:57
8
Bianca Mihai
@biancamihai
Jun 22 2015 10:57
thanks
yes working :)
nice
Christian Petersen
@fnky
Jun 22 2015 10:58
function largestOfFour(arr) {
// You can do this!
return arr.map(function (v) {
return Math.max.apply(Math, v);
});
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
ar2g
@ar2g
Jun 22 2015 10:58
heh nice
Bianca Mihai
@biancamihai
Jun 22 2015 10:59
even nicer @fnky
my solution:
Christian Petersen
@fnky
Jun 22 2015 10:59
.map and .filter are really useful
Bianca Mihai
@biancamihai
Jun 22 2015 10:59
function largestOfFour(arr) {
var max = [];
arr.forEach(function(arr){ max.push(Math.max.apply(Math,arr)); });
return max;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Christian Petersen
@fnky
Jun 22 2015 10:59
You made your own .map :D
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 10:59
@fnky thanks
@biancamihai thanks
Bianca Mihai
@biancamihai
Jun 22 2015 10:59
because you don;t use an extra var
save memory
great! :D
ar2g
@ar2g
Jun 22 2015 10:59
both excellent solutions!
Bianca Mihai
@biancamihai
Jun 22 2015 11:00
@ar2g my first solution didn’t look that nice ;)) I’m imporving my JS skills here in FCC
Christian Petersen
@fnky
Jun 22 2015 11:00
Certainly!
Chhavi24
@Chhavi24
Jun 22 2015 11:01
@biancamihai something like this
Bianca Mihai
@biancamihai
Jun 22 2015 11:02
@Chhavi24 looking now for that old project, too bad I didn’t used git back then :(
hope I’ll find it :D
ar2g
@ar2g
Jun 22 2015 11:02
@biancamihai how do you post code so it's properly formatted?
Bianca Mihai
@biancamihai
Jun 22 2015 11:02

at the start and at the end of your code
Christian Petersen
@fnky
Jun 22 2015 11:03
and if you want language specific you can do js
where js could be the extension of a language, e.g. css, html, etc.
ar2g
@ar2g
Jun 22 2015 11:03
thanks
Chhavi24
@Chhavi24
Jun 22 2015 11:03
@biancamihai I want the contents of the table to get updated on click
thanks :)
ar2g
@ar2g
Jun 22 2015 11:04
function largestOfFour(arr) {

var results = [];

for(var i = 0; i < arr.length; ++i) {
var temp =0;
for(var j = 0; j < arr[i].length; ++j) {
if(arr[i][j] > temp) {
temp = arr[i][j];
}
}
results.push(temp);
}

return results;
}
Christian Petersen
@fnky
Jun 22 2015 11:06
woa
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 11:08
@ar2g In this way I tried, but I missed the var between the two for loops :D
ar2g
@ar2g
Jun 22 2015 11:08
it's old school I know...
map / forEach is definitely the way to go
Bianca Mihai
@biancamihai
Jun 22 2015 11:09
@Chhavi24 I’m afraid there is no easy answer for you http://keith-wood.name/svg.html this is the documentation that I used to build that project with svg it was an app where you could customise your phone case with your images, so this might help you alter the generated svg on click on a area to show what you need ...
you can manipulate a svg using that documentation, it was all that I used then http://biancamihai.github.io/img/portfolio/casepicture.jpg
Hugo
@HugoNebreda
Jun 22 2015 11:32

One question about codepen.io with Zipline: Use the Twitch.tv JSON API
I don't know what I have to put to enable 'Access-Control-Allow-Origin'
All my http requests get "XMLHttpRequest cannot load"

 var url = "https://api.twitch.tv/kraken/streams/freecodecamp";
$.getJSON(url,function(result){$.each(result, function(i, field){
console.log("i: " +  i + " field: " + field);
});
});

Seems to be some kind of preconfiguration, but I cannot understand what it is.
Any help here?

Bianca Mihai
@biancamihai
Jun 22 2015 11:37
@HugoNebreda take a look here http://api.jquery.com/jquery.getjson/ at callback and jsonp
Nicholas Butterworth
@Nbutter
Jun 22 2015 11:38
@HugoNebreda you can't control access-control-allow-origin... it's up to the server you're hitting
Chhavi24
@Chhavi24
Jun 22 2015 11:39
@biancamihai Thanks for trying
:smile:
Hugo
@HugoNebreda
Jun 22 2015 11:41
Thanks @biancamihai and @Nbutter
I'll try to find out how to make it work with JsonP then
Steven Leiva
@StevenXL
Jun 22 2015 13:03
@Nbutter At you a developer? You seem to be very knowledgeable on a lot of diff. topics.
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:04
nope, just a camper.. but i did a 3-month paid bootcamp right before i came to FCC so i got a pretty big dose of javascript on many/most of the same topics FCC covers
haven't learned Angular yet and studying Mongo right now ;)
in my program we did a ton of work accessing API's via jquery
like, weeks and weeks of it
Maxim Orlov
@Maximization
Jun 22 2015 13:06
@Nbutter which bootcamp is that?
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:07
General Assembly in nyc
Steven Leiva
@StevenXL
Jun 22 2015 13:07
@Nbutter That's awesome. I'm going to Dev Bootcamp myself soon.
They focus on Rails so I got comfortable with Ruby (for a beginner) and figured I'd learn JavaScript via FCC.
I can't wait.
Mind if I message you so we can talk a bit of your experience w/ a bootcamp?
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:08
oh cool! GA used to focus on rails but recently switched to a very JS-centric approach
sure!
Steven Leiva
@StevenXL
Jun 22 2015 13:08
/msg @Nbutter Hi!
woops, that doesn't work.
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:09
click my avatar image, that seems to work
k
Argentoratum
@Argentoratum
Jun 22 2015 13:22
hi! how can I have a value for a certain key for an object? So say
o={key:'value'} , I can write o[key] if I know key already! but if it's not static?
so for example a function receives an object
and then I know Object.keys(o), but then how can i have the values also?
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:24
@Argentoratum you can loop through the keys to find the values, maybe using map()
what is the end result you're after?
Argentoratum
@Argentoratum
Jun 22 2015 13:27
I'm solving a bonfire (Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).)
this is where I am, and I look for a way to compare in the place of ????
function where(collection, source) {
var arr = [];

for (var i=0; i<collection.length;i++)
{

var match=true; //Assume that it is good

for (var j=0;j<Object.keys(source).length;j++){
if (!(collection[i].hasOwnProperty(Object.keys(source)[j]) && collection[i]))
{
match=false;
}
//If it's still a good match
arr.push(collection[i]);
}
}

return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
so instead of && collection[i]))
So i'm going through collection in the outer loop loop, and in the inner function try to see for each property in source if it is in collection[i] and then to see if it's value equals with collection[i] also
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:33
hey, let me look at this for a sec ; )
Argentoratum
@Argentoratum
Jun 22 2015 13:34
thanks!:)
Hugo
@HugoNebreda
Jun 22 2015 13:34
@Argentoratum
Try to do this at the begining
  var property = Object.keys(source); // you only need to do this once
then you can use to access that property
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:34
so as far as i can tell, this code will push everything into arr
Hugo
@HugoNebreda
Jun 22 2015 13:35
and to check if the current item that you're checking has it
Argentoratum
@Argentoratum
Jun 22 2015 13:35
yes, unfortunately it will:)
thanks @HugoNebreda , this should make it more readable (and faster, i guess)
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:36
this has to do with the way your for loop and if statement are structured
Hugo
@HugoNebreda
Jun 22 2015 13:36
collection[i].hasOwnProperty(property)
and then you can use
collection[i][property] ===  ? // put something to compare the value
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:36
basically if you only want to push things that match a certain condition, assume it is true, then loop through, and if you can prove it to be false, you want to exit the loop
then if you get to the end without exiting, you can push it, because you've now proved it's true for all of the elements
so you're missing the part where you exit the loop on a false result
does that help at all?
Argentoratum
@Argentoratum
Jun 22 2015 13:40
I'm doing that, on the outer loop i have var match=true; and then testing

it is more readable,and better because it stops comparing if don't have the same property but still have some question marks...
var arr = [];
var properties = Object.keys(source);

for (var i=0; i<collection.length;i++)
{

  var match=true; //Assume that it is good

for (var j=0;j<properties.length;j++){
if (collection[i].hasOwnProperty(properties[j]))
{
if !(????) {match=false;} //not the same value
}
else
{
//If doesn't even have the same property
match=false;
}
//If it's still a good match
arr.push(collection[i]);
}
}

return arr;
}

sorry, again:
  var arr = [];
var properties = Object.keys(source);

for (var i=0; i<collection.length;i++)
{

var match=true; //Assume that it is good

for (var j=0;j<properties.length;j++){
if (collection[i].hasOwnProperty(properties[j]))
{
if !(????) {match=false;} //not the same value
}
else
{
//If doesn't even have the same property
match=false;
}
//If it's still a good match
arr.push(collection[i]);
}
}

return arr;
}
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:42
you're testing, but what is the consequence?
Hugo
@HugoNebreda
Jun 22 2015 13:42
@Argentoratum
I have like 15 mins free want to pair and see what happens together?
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:43
if you set match to "false", so what? your code doesn't do another check before it pushes collection[i] into arr
Jun 22 2015 13:43
for (var i = 10; i = 0; i--) {
console.log(i);
}
why wouldn't this work :(
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:44
@saadbassi1 the middle of the for loop conditions shouldn't be an equals sign
try "i > 0" or "i >=0"
Jun 22 2015 13:45
2nd one works
Argentoratum
@Argentoratum
Jun 22 2015 13:45
@HugoNebreda , thanks, but i don't know if i can do pair programming, I'm on Ubuntu
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:45
it means "keep going while this condition is true"
Jun 22 2015 13:45
I am just trying to understand whats wrong with i=0 or i<0?
sorry
i<1
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:45
so you were saying: "let i be 10. now run the loop if i is zero"
Argentoratum
@Argentoratum
Jun 22 2015 13:45
@Nbutter yes, thanks, i see now
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:46
and the computer was saying, "well, i guess i don't have to run the loop then..."
Jun 22 2015 13:46
oh got it :D
Hugo
@HugoNebreda
Jun 22 2015 13:46
@Argentoratum ok no prob
Jun 22 2015 13:46
but what about i<1 shouldn't that work?
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 13:46
Where are you on the FreeCodeCamp Map ? :)
Bianca Mihai
@biancamihai
Jun 22 2015 13:46
@saadbassi1 for (var i = 10; i >= 0; i--) === starting from 10 execute something as long as i >= 0 and at every loop do i--
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:46
same problem. you are starting out at i=10
so you will never get going if you are saying to only run if i < 1
Jun 22 2015 13:47
so run the loop until i < 1 which means zero
aaahh
got it now
thank you so much :)
Nicholas Butterworth
@Nbutter
Jun 22 2015 13:47
no problem! for loops are a pain to learn for everyone ; )
but super super super super useful later on
Lightwaves
@Lightwaves
Jun 22 2015 13:47
careful with that loop it will run 11 times not 10
in case you meant for it to run 10
Jun 22 2015 13:48
nah thats how I intend it to run :)
Lightwaves
@Lightwaves
Jun 22 2015 13:49
just making sure :)
Hugo
@HugoNebreda
Jun 22 2015 13:49

So, here is my question.
I have this function:

function getData(channels) {
channels.map(function(channel) {
$.getJSON(channel.apiUrl, function(result) {$.each(result, function(i, field) {
if (i == "stream") {
if (field != null) {
channel.status  = "online";
} else {
channel.status = "offline";
}
}

});
});
});

};

but the problem is, that property "status" never get updated to the value.
I also tried to prototype a "setStatus" function but doesn't seem to work.

The channels object is okey, I'mean the line chanel.status = "offline" is executed for sure.

Argentoratum
@Argentoratum
Jun 22 2015 13:49
so now, I got it working for the example...
if (!(collection[i].last==source.last))
but instead of "last" it should be properties[j] ... (which is also =last)
how to do that?
Omar
@oab00
Jun 22 2015 13:50
Hugo
@HugoNebreda
Jun 22 2015 13:50
Omar
@oab00
Jun 22 2015 13:51
it does show medrybw as online for me
Hugo
@HugoNebreda
Jun 22 2015 13:53
yes?
maybe I should just refresh cache
Omar
@oab00
Jun 22 2015 13:54
the code on the codepen now uses setStatus tho
Hugo
@HugoNebreda
Jun 22 2015 13:54
hmmm
not working for me
the problem is that I'm loging the channel info
an status remains "unchecked" , that is its initialization value
Omar
@oab00
Jun 22 2015 13:56
woah really? for me it shows 'online' and 'offline'
in the logs
Hugo
@HugoNebreda
Jun 22 2015 13:57
:worried:
I refreshed and it still the same.
I'm on chrome I'm going to try it out on FF
Omar
@oab00
Jun 22 2015 13:57
forked the pen to show u http://codepen.io/oab00/pen/VLMJGp
does it work in the forked pen ?
Hugo
@HugoNebreda
Jun 22 2015 13:59
not for me
Omar
@oab00
Jun 22 2015 14:00
o_o
Hugo
@HugoNebreda
Jun 22 2015 14:00
ok, in the log, there is a line just after I set the value, and it seems that is "online"
but if you look at the code that later prints on screen the list
it also checks if is online or not to print an "X" or a "V" glyphicon
Omar
@oab00
Jun 22 2015 14:01
yea I see it all X for some reason
Hugo
@HugoNebreda
Jun 22 2015 14:05
well @oab00 thanks for your time
I'm having a long break so maybe later I come up with the solution.
If you see something PM me if you want :smiley:
Omar
@oab00
Jun 22 2015 14:10
ok found the problem
when you call channels.map() it doesn't update the channels array
you need to assign it
channels = channels.map();
Hugo
@HugoNebreda
Jun 22 2015 14:13
You rock!
It happens me all the time
ThBn
Thanks @oab00
Omar
@oab00
Jun 22 2015 14:16
actually .. I might be wrong .. did it work?
keagan goetsch
@misterrorypond
Jun 22 2015 14:18
This message was deleted
Hugo
@HugoNebreda
Jun 22 2015 14:19
I cannot try ir
It*
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 14:38
Hi, I'm struggling at algorithm part of the FreeCodeCamp. Can someone tell me a website or something that can help me with this?
ar2g
@ar2g
Jun 22 2015 15:00
@copywithpaste Eloquent Javascript
@copywithpaste or Project Euler
Dragomir-Ficard Mihai-Alexandru
@dfmalexandru
Jun 22 2015 15:02
@ar2g Thanks :+1:
ar2g
@ar2g
Jun 22 2015 15:02
I'm having an issue with http://www.freecodecamp.com/challenges/bonfire-make-a-person - 5/6 tests pass but the first one doesn't... help please?
@copywithpaste no worries!
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:04
@ar2g Can I see your code?
ar2g
@ar2g
Jun 22 2015 15:04
'''
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:04
The test wants all the constructor methods inside the constructor function.
ar2g
@ar2g
Jun 22 2015 15:05
var Person = function(firstAndLast) {
var names = firstAndLast.split(' ');
this.first = names[0];
this.last = names[1];
};

Person.prototype.getFirstName = function() {return this.first;};
Person.prototype.getLastName = function() {return this.last;};
Person.prototype.getFullName = function() {return this.first + ' ' + this.last;};
Person.prototype.setFirstName = function(first) {this.first = first;};
Person.prototype.setLastName = function(last) {this.last = last;};

Person.prototype.setFullName = function(firstAndLast) {
var names = firstAndLast.split(' ');
this.first = names[0];
this.last = names[1];
};

var bob = new Person('Bob Ross');
bob.getFullName();
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:05
The first test checks if there are six items defined in the object constructor.
ar2g
@ar2g
Jun 22 2015 15:05
@azuriolinist yeah, I didn't quite get that
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:06
Instead of setting variables, put all the methods inside the object constructor and use the firstAndLast variable that is already defined in the function to get/set the name.
So, for example, let's say you call getFirstNameon bob.
this is the code, which should be inside the function Person.
this.getFirstName = function() {
return firstAndLast.split(' ')[0];
};
ar2g
@ar2g
Jun 22 2015 15:07
@azuriolinist AHA
@azuriolinist fairly new to JS, thanks for clearing that up
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:08
so you don't need to set any variables at all! just put the functions inside the Person constructor.
No prob. :)
ar2g
@ar2g
Jun 22 2015 15:09
@azuriolinist is it idiomatic to use field variables then?
@azuriolinist sorry NOT to use fields I meant
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:10
Nah. It's really up to you. I usually use variables myself, until I realized you could do that up there. ^^
ar2g
@ar2g
Jun 22 2015 15:12
@azuriolinist OK cool. Thanks again :) that leaves pairwise in the intermediate section :D
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:13
Good luck! :D
ar2g
@ar2g
Jun 22 2015 15:13
cheeers!
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:13
@azuriolinist that bonfire gave me a ton of trouble too. it was pretty uninituitive to me so solve it like that.
Alyssa Alvarez
@AlysCole
Jun 22 2015 15:15
I know. I'm still curious as to how a variable outside the method function can still remain after the function is called.
I guess it remains in the object?
ar2g
@ar2g
Jun 22 2015 15:16
Or is this something to do with hoisting? Oh, the mysterious wonders of JS scope...
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:16
well, i think when you set the object property in the method it's the same as if you set the object property anywhere else
the object retains the property
ar2g
@ar2g
Jun 22 2015 15:18
sure, that makes sense.
Jonathan
@jonathantimm
Jun 22 2015 15:22
Does anyone know who I should contact for technical support on my FCC account?
Yesterday I finished almost all of the html/css and bootstrap waypoints, and now all of that progress is gone, and it's the second time it's happened.
Cristalin Solis
@Neebulo
Jun 22 2015 15:24
@ar2g: so I am trying to make a function for each of these 3 verbals. But Im not sure how to effectively translate them into javascript format. I figured out how to create the hotOrNot function but the other verbals in this link, Im not sure how to format to create its desired results. http://repl.it/t9j
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:29
are you going to FreeCodeCamp.org by any chance?
@jonathantimm
Jonathan
@jonathantimm
Jun 22 2015 15:31
yes
is that the problem?
@jeremiahbiard
I just tried .com and it said server not foudn
*found
ar2g
@ar2g
Jun 22 2015 15:33
@jonathantimm I had that earlier - but my browser was hitting https
@jonathantimm but http://www.freecodecamp.com worked eventually
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:34
it is, FreeCodeCamp.org is the test server and it doesn't save your progress
Jonathan
@jonathantimm
Jun 22 2015 15:35
Oh crap
ar2g
@ar2g
Jun 22 2015 15:35
@Neebulo could you post any attempts you've made so far?
oh dude that sucks
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:36
@jonathantimm you can skip them if you don't feel like going through them again
just mark them finished and move on
Jonathan
@jonathantimm
Jun 22 2015 15:36
You can't actually skip the waypoints since they were updated
you have to enter the correct code
With the catphoto app lesson
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:36
you can start anywhere in the map you want to
Jonathan
@jonathantimm
Jun 22 2015 15:36
oh I guess that's true
I guess I'm neurotic and I want to see the green check mark next to all the work I did!
But I should just get over it
ar2g
@ar2g
Jun 22 2015 15:37
OR you could just do the last cat app one
Jonathan
@jonathantimm
Jun 22 2015 15:37
yeah, I do have to finish the bootstrap section
but I should be using the .com from now on, right?
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:37
yes
Jonathan
@jonathantimm
Jun 22 2015 15:38
Alright. So I guess I'll just try that periodically until it works, heh
ar2g
@ar2g
Jun 22 2015 15:39
commiserations
Jonathan
@jonathantimm
Jun 22 2015 15:39
ar2g
@ar2g
Jun 22 2015 15:41
you should check out Project Euler too, that's fun
Once you solve the prob you can see solutions in other programming languages, pretty interesting
Jonathan
@jonathantimm
Jun 22 2015 15:48
Does it have beginner level stuff? I definitely will
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:48
It's more of an algorithm thing like Hackerrank or Topcoder
ar2g
@ar2g
Jun 22 2015 15:48
yeah it starts easy but gets harder
Ariel
@ArielLeslie
Jun 22 2015 15:49
@jonathantimm It starts straightforward and gets more complicated. It's about the algorithms/problem solving more than the coding (which is good because the coding is the easy part :D )
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:49
As a total beginner I'd say stick with the FreeCodeCamp curriculum and try not to get distracted with all the awesome, fun, cool, free stuff out there to play with
Waqar Hocain
@waqarHocain
Jun 22 2015 15:49
hi
anyone here on "Map the Debris" bonfire?
ar2g
@ar2g
Jun 22 2015 15:49
I haven't tried HR / TC @jeremiahbiard - any good?
Have to say the freecodecamp curriculaum is really nicely thought through.
@waqarHocain yeah I did that, are you stuck?
Waqar Hocain
@waqarHocain
Jun 22 2015 15:51
@ar2g yep
my code works, if array has only one object
ar2g
@ar2g
Jun 22 2015 15:52
are you using map?
Waqar Hocain
@waqarHocain
Jun 22 2015 15:53
@ar2g can you look at my code?
ar2g
@ar2g
Jun 22 2015 15:53
@waqarHocain sure, pm me
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 15:53
I like hackerrank
i don't feel confident enough in my algorithm knowledge to play on TopCoder
ar2g
@ar2g
Jun 22 2015 15:56
@waqarHocain OK, wrap your logic up in an anonymous function that's applied by map to each element of the incoming array
@jeremiahbiard TopCoder sounds a bit mental then. have you read any of Sedgewick's books? I keep meaning to but...
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 16:00
Well, TopCoder is more of a competition platform
Hackerrank is more of a, hey, do some algorithm challenges, learn something, it'll be fun
Jonathan
@jonathantimm
Jun 22 2015 16:00
@jeremiahbiard @ar2g just fyi I just got the .com to work and all my progress is still there! I am officially a happy camper and can get back to my waypoints! Wooo!!! Thx guys
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 16:01
@jonathantimm right on!
ar2g
@ar2g
Jun 22 2015 16:01
@jonathantimm WOOT! Nice one!
@jeremiahbiard It's all fun until you're still up at 5 am hunched over the macbook air
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 16:04
@ar2g what's not fun about that :smile:
ar2g
@ar2g
Jun 22 2015 16:06
@jeremiahbiard yeah we love it really
Jun 22 2015 16:08

'code'
/jshint multistr:true /
text = "bla bla bla saad anam umair bla bla shiz \
dawg bla saad bla bla bla yo dawg";
var hits = [];
for (i=0 ; i<text.length ; i++){
if(text[i]==="S"){
for(j=i ; j<=myName.length ; j++){

    }
}

}
'code'

markdown messed it up. LOL I 'm a noob :/
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 16:10
Jun 22 2015 16:12
codecadmy says that your 2nd loop should have the condition of j<=i+myName.length
which is what I am trying to understand. Shouldn't j<=myName.length be sufficient?
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 16:13
no, because it's going to break when you get near the end of text because text.length[i] + myName.length is past the end of the string
er, well, the code in the explanation is wrong but i think the meaning comes across
Jun 22 2015 16:17
trying again :worried:
Jeremiah Biard
@jeremiahbiard
Jun 22 2015 16:17
but you understand what i was trying to say right?
Jun 22 2015 16:21
yes. thank you
Suzanne Atkinson
Jun 22 2015 17:07
@ar2g did you get pairwise yet? I'm stuck on it! I've seen answers but really need to puzzle it out for myself.
Jun 22 2015 17:33

Hi all, been trying to figure out the Mutations bonfire for ages and for some reason the first test is failing. Please help!

So far I have:

function mutation(arr) {
var i = 0,
match = 0;

while(i <= arr1.length){
if(arr1.indexOf(arr[1][i]) > -1){
match++;
i++;
} else {
i++;
}
}

if(match == arr1.length){
return true;
} else {
return false;
}

}

mutation(['hello', 'hey']);

Moisés Man
@moigithub
Jun 22 2015 17:35

@thewebologist if all chars from arr1 is on arr2.. then is true... but not necessary need to match length.. example

mutation(['abc','aaaaabbbbbbbbccccccddddd'])

Grace
@dogbot101
Jun 22 2015 17:37
I'm on the mutation bonfire as well and also need help:

///function mutation(arr){
var str = arr[0].toLowerCase().split("");
var str2 = arr1.toLowerCase().split("");
for(var i=0; str2.length;i++);{
if(str.indexOf(str2[i]) === -1) {
return false;}
else {
return true;
}

}
}

mutation(['hello', 'hey']);
///

Jun 22 2015 17:37
@moigithub The match length only counts characters from the second array that are matched in the first array. So in theory should match the length of the second array
Grace
@dogbot101
Jun 22 2015 17:37

function mutation(arr){
var str = arr[0].toLowerCase().split("");
var str2 = arr1.toLowerCase().split("");
for(var i=0; str2.length;i++);{
if(str.indexOf(str2[i]) === -1) {
return false;}
else {
return true;
}

}
}

mutation(['hello', 'hey']);

Moisés Man
@moigithub
Jun 22 2015 17:40
@thewebologist whats arr1 ??
@dogbot101 remember return will exit the forloop, so u not checking all characters but first one only
Grace
@dogbot101
Jun 22 2015 17:42
thank you for the feedback @moigithub
EngineeredEdge
@EngineeredEdge
Jun 22 2015 17:47
holaaaa
anyone here want to hlep me understand this http://stackoverflow.com/a/22063440/4499429
Suzanne Atkinson
Jun 22 2015 17:51
did you read thsi commenters interpretation:
" For every item in the array (reduce), select all other items, permute them (recursively), and concat to this item"
probabaly easiest to copy/paste that code into a codepen or replit and unchain the methods so you can see what each step does
EngineeredEdge
@EngineeredEdge
Jun 22 2015 17:51
i have
my [limited] understanding of reduce kind of implies that the end result is a single item
instead of a list of permutations, like this one ends up with
Nathan
@terakilobyte
Jun 22 2015 17:56
an array of arrays is a single item
Suzanne Atkinson
Jun 22 2015 17:56
I see what you're asking. I am also not an expert in functional programming usage, but the reduce returns a concatenation
Nathan
@terakilobyte
Jun 22 2015 17:56
notice what is being passed in as the accumulator for reduce
an array construct
Suzanne Atkinson
Jun 22 2015 17:56
so the concat is the single item
lol
Nathan
@terakilobyte
Jun 22 2015 17:57
whatever is passed in as the accumulator will be the type that is returned
Suzanne Atkinson
Jun 22 2015 17:57
^^ I learned from him^^
Nathan
@terakilobyte
Jun 22 2015 18:00
var inputArray = [1, 2, 3];

var result = inputArray.reduce(function permute(res, item, key, arr) {
return res.concat(arr.length > 1 &&
arr.slice(0, key)
.concat(arr.slice(key + 1))
.reduce(permute, []) // here in the recursive call to permute, an empty array as the accumulator
.map(function(perm) {
return [item].concat(perm);
})
|| item);
}, []); // here, an empty array is passed in as the initial accumulator value
EngineeredEdge
@EngineeredEdge
Jun 22 2015 18:00
Nathan
@terakilobyte
Jun 22 2015 18:01
again, because the accumulator is an array, the return from reduce will be an array
we can analyze the function if you want
EngineeredEdge
@EngineeredEdge
Jun 22 2015 18:02
also, there is a syntax quirk that I haven't seen before
the
res.concat(arr.length > 1 &&
arr.slice(0, key)
Nathan
@terakilobyte
Jun 22 2015 18:02
the && ?
Suzanne Atkinson
Jun 22 2015 18:02
cool thanks @terakilobyte
Nathan
@terakilobyte
Jun 22 2015 18:03
it's a very short way to say (if this is true do this)
try it in a repl, one sec to let me get you some starter code
EngineeredEdge
@EngineeredEdge
Jun 22 2015 18:03
like that
Nathan
@terakilobyte
Jun 22 2015 18:04
essentially identical to a ternary
Jessi L Wasell
@JessiW
Jun 22 2015 18:06
Hi - I'm working on the Title Case a Sentence Bonfire. My code isn't complete - I'm still trying to build it - but I'm wondering if I need a regex to select the correct letters (the first letter of every word) and if so, what would that look like? Also, do I need to use replace()?
Nathan
@terakilobyte
Jun 22 2015 18:07
regex isn't necessary to get the individual letters
and I didn't use replace
Jessi L Wasell
@JessiW
Jun 22 2015 18:07
Okay - how to I make sure I'm selecting the right characters with charAt() then?
Argentoratum
@Argentoratum
Jun 22 2015 18:07

Hi! Any tips why this solution isn't working?

function convert(str) {
return str
.replace("&", "&amp;")
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace('"', "&quot;")
.replace("'", "&apos;");
}

convert('<>');

http://www.freecodecamp.com/challenges/bonfire-convert-html-entities

Suzanne Atkinson
Jun 22 2015 18:10
it works for me, as in the code does exactly what you programmed. but is it not passing the tests? What errors are you getting?
Argentoratum
@Argentoratum
Jun 22 2015 18:12
@AdventureBear , it does not pass for <>
Suzanne Atkinson
Jun 22 2015 18:12
what does the error say?
EngineeredEdge
@EngineeredEdge
Jun 22 2015 18:13
@terakilobyte that does help with my understanding of that function a lot
Argentoratum
@Argentoratum
Jun 22 2015 18:13
assert.strictEqual('<>', '<>', 'should escape characters');
should escape characters: expected '<>' to equal '<>'
Suzanne Atkinson
Jun 22 2015 18:15
I think that it should only covert if it's inside double quotes, and if not it should escape it (not convert) because fi you think about html code, you need the <> characters. But you'd want to convert a "<" character
Steven Leiva
@StevenXL
Jun 22 2015 18:16
is it possible to pass in extra arguments to a callback function than what the outter function calls it with?
Suzanne Atkinson
Jun 22 2015 18:16
actually i'm not sure becuase my code that passed before doesn't pass now. @Argentoratum
and I get the same error
Argentoratum
@Argentoratum
Jun 22 2015 18:16
@AdventureBear , yes, maybe, I wondered why it recommends RegExp as a resource...:)
Suzanne Atkinson
Jun 22 2015 18:16
@StevenXL I think you can throw in as many arguments as you want.
Logan Tegman
@ltegman
Jun 22 2015 18:17
@Argentoratum That test is broken in the current build. Someone said the fix should be deployed in a couple days
Suzanne Atkinson
Jun 22 2015 18:17
Sorry guys if I'm not being super helpful. I'm trying
Nathan
@terakilobyte
Jun 22 2015 18:17
somehow that challenge got broken on master due to a bad commit
skip it for now, we'll roll out a fix for it shortly
EngineeredEdge
@EngineeredEdge
Jun 22 2015 18:17
it does appear borken
Argentoratum
@Argentoratum
Jun 22 2015 18:17
thank you all!
by the way, how would it be possible to NOT escape html tags while escaping the others?
Jun 22 2015 18:26
This message was deleted
EngineeredEdge
@EngineeredEdge
Jun 22 2015 18:28
@terakilobyte aha! the english explanation finally matches with what's going on
Jun 22 2015 18:29

@moigithub Sorry code didn't format, first time using gitter

function mutation(arr) {
var i = 0,
match = 0;

while(i <= arr[1].length){
if(arr[1].indexOf(arr[1][i]) > -1){
match++;
i++;
} else {
i++;
}
}

if(match == arr[1].length){
return true;
} else {
return false;
}

}

mutation(['hello', 'hey']);

should be arr1 (arr straight brackets 1)

Santiago Melo
@smeloa
Jun 22 2015 18:39
Hi anyone able to help with: Bonfire: Sum All Primes?
Moisés Man
@moigithub
Jun 22 2015 18:42
@thewebologist u need to check if each character from 1 word.. is on the other word.. like :
h is in "hey" ?
e is in "hey" ?
l is in "hey" ? (x2)
o is in "hey" ?
so if all true.. return true
@thewebologist on uf IF condition u using same arr1.. so u checking all chars from the same word... h,e,y on "hey" ,, and should be h,e,l,l,o on " hey"
Suzanne Atkinson
Jun 22 2015 18:47
@smeloa maybe what do you need? I had a lot of fun with that one
Jun 22 2015 18:47

Hey guys I cant figure out what is wrong with this code I wrote (I am on the "Waypoint: Size your Images”):

<style>
.small-image {
width: 100px;
}
</style>

<img class='small-image'> 'https://bit.ly/fcc-kittens'</img>

My objective is to create a CSS class called “small-image” and adjust the width of the image. I am just unsure of how to incorporate the class into the “img" and “src” code/tags. Thanks in advance and sorry for the dumb question.

Bianca Mihai
@biancamihai
Jun 22 2015 18:48
<img class="small-image" src="https://bit.ly/fcc-kittens"/>
use the src attribute @JC713
Jun 22 2015 18:48

@moigithub I thought I was doing that but on going through my code with a fresh pair of eyes can see that mistake. Now I think I'm home and hosed if I throw .toLowerCase in there somewhere.

Thanks for the help :)

Jun 22 2015 18:49
When would I have to do a closing tag of </___> versus just /> ?
Thanks btw :D
Bianca Mihai
@biancamihai
Jun 22 2015 18:49
well <div> bla bla bla </div>
<img src=“bla bla” />
or <br />
Jun 22 2015 18:50
Alright. So it is based on the tag type? Thanks for the help :D
Santiago Melo
@smeloa
Jun 22 2015 18:50
function sumPrimes(num) {
var sum = 0;
for (var i = 2; i <= num; i++) {
if (i%i===0 && (i%2!==0 || i%3!==0)) {
sum += i;
}
return sum;
}
}
sumPrimes(10);
Bianca Mihai
@biancamihai
Jun 22 2015 18:50
good luck @JC713 with the other challenges ;)
Santiago Melo
@smeloa
Jun 22 2015 18:50
here is what the code looks like right now
Jessi L Wasell
@JessiW
Jun 22 2015 18:51
I'd like to have someone look at my code for the Bonfire: Title Case a Sentence - how do I make my code appear as a block of code in here?
Ariel
@ArielLeslie
Jun 22 2015 18:52
there's markdown help on the right of your text entry box
Jessi L Wasell
@JessiW
Jun 22 2015 18:52
okay - thanks
Ariel
@ArielLeslie
Jun 22 2015 18:53
this = code;
#I think
Jessi L Wasell
@JessiW
Jun 22 2015 18:54
Here's my code so far - I think its incomplete - but I'm not sure what I'm missing - it seems to return only the first letter of every sentence instead of capitalizing the first letter of every word in the sentence.....function titleCase(str) { var newString = str.charAt(0).toUpperCase(); for(var i = 0; i <newString.length; i++); return newString; } titleCase("I'm a little tea pot");
I used three  before and after my code - not sure why it didn't show up properly?
Moisés Man
@moigithub
Jun 22 2015 18:56
"hello".charAt(0) == h (take char at position 0 )
Jessi L Wasell
@JessiW
Jun 22 2015 18:56
yes - so I need to take the zero out?
Moisés Man
@moigithub
Jun 22 2015 18:57
u need to append all rest of chars.. to complete/reassemble the word
rwickline11
@rwickline11
Jun 22 2015 18:58
how can you push something into one array inside a multidimensional array?
Jessi L Wasell
@JessiW
Jun 22 2015 18:58
@moigithub so I have to list out each word like you showed above?
Suzanne Atkinson
Jun 22 2015 18:59
@smeloa I think that code only works up to the number 6 or so. what happens with the numbre 10?
i think that code is calling 10 a prime as well
Moisés Man
@moigithub
Jun 22 2015 19:00
@JessiW u can use slice to get all rest of chars http://www.w3schools.com/jsref/jsref_slice_string.asp
Jessi L Wasell
@JessiW
Jun 22 2015 19:00
okay - thanks - I'll look at the link....I wondered if I needed slice!
Santiago Melo
@smeloa
Jun 22 2015 19:01
expect(sumPrimes(10)).to.be.a('number');
expect(sumPrimes(10)).to.equal(17);expected 2 to equal 17
expect(sumPrimes(977)).to.equal(73156);expected 2 to equal 73156
so it seems like it isn't iterating
or looking at the second part of the if statement
Jun 22 2015 19:03
Question folks
var whileCounter = 0;
while(whileCounter<10){
console.log(whileCounter);
whileCounter++;
}
why does this while loop prints an additional 9?
shouldn't it go from 0 to 9 and then stop? it prints an addition 9
rwickline11
@rwickline11
Jun 22 2015 19:04
you should use a for loop for that it seems
Moisés Man
@moigithub
Jun 22 2015 19:04
@smeloa
first u need a loop.. to go from 1 to NUM (0+a = a,,, so 0 dont really count )
also u need to check somehow.. if (each) num (on that range) is PRIME
if its prime.. sum
Jun 22 2015 19:06
any one?
Moisés Man
@moigithub
Jun 22 2015 19:06
cuz 9 < 10 ??
Jun 22 2015 19:07
but it prints 9 twice
Moisés Man
@moigithub
Jun 22 2015 19:07
ah
Jun 22 2015 19:07
0 1 2 3 4 5 6 7 8 9 9
rwickline11
@rwickline11
Jun 22 2015 19:13
when I typed out the code it didn't print 9 twice. did you try reloading the page or simply retyping it?
it's worked for me before
Jun 22 2015 19:17
seems like a bug in codecademy. tried in chrome dev tools and it worked fine
thanks for help
rwickline11
@rwickline11
Jun 22 2015 19:17
no problem. be sure to let codecademy know
rwickline11
@rwickline11
Jun 22 2015 19:23
how can you push something into one array inside a multidimensional array?
Jun 22 2015 19:59

if (!isNaN(arguments[0]) && arguments.length == 1) {
return function(x) {
return arguments[0] + x;
};

} else if (!isNaN(arguments[0]) && !isNaN(arguments1)){
return arguments[0] + arguments1;

} else {
return undefined;
}

}

Krzysztof Miąsko
Jun 22 2015 19:59
arr[x].push();
Jun 22 2015 19:59
Can anyone help me with the arguments optional bonfire?
Matthew Vogel
@matthewsvm
Jun 22 2015 19:59
I asked this question last night, and then I went to bed right away. If anyone has advice, please let me know:
function smallestCommons(arr) {
arr = arr.sort();
var holder = [];

// if some number is divisible by arr[0] && arr[1]...&&...arr[last]
// return it

// find the factors; for the factor that happens the most
// in any number, multiply them together.
// i.e. 6, 10, 27
// 2 * 3,
// 3 * 3 * 3
// 5 * 2
// so the answer is 2 * 3 * 3 * 3 * 5 = 270
// 270 is the least common multiple of these three numbers.
var summit = arr[0];
var someIt = arr[1];

for(i = summit; i <= someIt; i++) {
holder.push(i);
}

return holder;
}

smallestCommons([99, 87]);
returning “holder” gives me the array…I just wanted to make sure I have all the right numbers in there.
Krzysztof Miąsko
Jun 22 2015 20:04
yep
Matthew Vogel
@matthewsvm
Jun 22 2015 20:05
But now I want to find the least common multiple.
Krzysztof Miąsko
Jun 22 2015 20:10
i did it by bruteforce method
Matthew Vogel
@matthewsvm
Jun 22 2015 20:10
are you talking to me @kmiasko ?
Krzysztof Miąsko
Jun 22 2015 20:10
yep
Matthew Vogel
@matthewsvm
Jun 22 2015 20:10
so you did a bunch of loops?
Krzysztof Miąsko
Jun 22 2015 20:11
yes, that for loop wrapped in while loop
Matthew Vogel
@matthewsvm
Jun 22 2015 20:11
hmmm…ok.
Krzysztof Miąsko
Jun 22 2015 20:12
and i just checked if modulo of all the numbers eq 0
in that for loop
Matthew Vogel
@matthewsvm
Jun 22 2015 20:12
ok, instead of pusing into an array?
Krzysztof Miąsko
Jun 22 2015 20:13
yep
Matthew Vogel
@matthewsvm
Jun 22 2015 20:13
when you say modulo of all the numbers do mean all the factors?
if all the factors of all the numbers === 0?
Krzysztof Miąsko
Jun 22 2015 20:19
omg, i don't think clearly today ;x if modulo of that bruteforced number by every number in your holder array will be 0, then it's your number
Matthew Vogel
@matthewsvm
Jun 22 2015 20:20
I gotcha
You said it right, I just didn’t understand.
I can’t think of a better way than yours.
Krzysztof Miąsko
Jun 22 2015 20:21
no problemmo :)
Matthew Vogel
@matthewsvm
Jun 22 2015 20:24
Perhaps a way to avoid brute force might be to use a forEach() or map() method? I don’t know. I might just loop it out.
Jun 22 2015 20:25
Alex
@wishe
Jun 22 2015 20:57

function findLongestWord(str) {
var splitStrings = str.split(' ');

for (var i = 0; i < splitStrings.length; i++) {
return splitStrings[i];
}

}

findLongestWord('The quick brown fox jumped over the lazy dog');

Whats wrong with this loop?

Krzysztof Miąsko
Jun 22 2015 21:01
"return" returns from the function your first array item
Jonathan
@jonathantimm
Jun 22 2015 21:02
Does anyone see anything wrong with this code?
$(document).ready(function() {$('#text').click(function () {
$(this).addClass('.highlighted'); }); }); Krzysztof Miąsko @kmiasko Jun 22 2015 21:02 remove the dot it's only for selectors Jonathan @jonathantimm Jun 22 2015 21:03 the dot in highlighted? Krzysztof Miąsko @kmiasko Jun 22 2015 21:03 yep Jonathan @jonathantimm Jun 22 2015 21:03 ohhh cause 'addClass' knows it's going to have a class as an input so you don't have to put the dot/ Krzysztof Miąsko @kmiasko Jun 22 2015 21:03 :) Jonathan @jonathantimm Jun 22 2015 21:03 ? Krzysztof Miąsko @kmiasko Jun 22 2015 21:04 yes Jonathan @jonathantimm Jun 22 2015 21:04 thanks so much Krzysztof Miąsko @kmiasko Jun 22 2015 21:04 you're welcome Jonathan @jonathantimm Jun 22 2015 21:04 seems like it'll take a while to get the hang of jquery Alex @wishe Jun 22 2015 21:05 kmiasko, how do i loop it then? Krzysztof Miąsko @kmiasko Jun 22 2015 21:06 your loop is okey, just don't return from it, find a longest word in that loop and return the word outside it after a return statement your function exits, the loop goes just once Alex @wishe Jun 22 2015 21:11 thankyou kmiasko Krzysztof Miąsko @kmiasko Jun 22 2015 21:12 np Alex @wishe Jun 22 2015 21:48 In the tutorials i used to declare functions like var thisIsFunction = function() { and in these bonfires its just function functionName() [ like in php, have i missed something ? tjstinso @tjstinso Jun 22 2015 21:52 i had a similar question coming from java here is some light reading: http://kangax.github.io/nfe/ Alex @wishe Jun 22 2015 21:53 Thankyou Steven Leiva @StevenXL Jun 22 2015 21:58 Hi. I was wondering if anyone could help me with my code. I think I am getting the correct answer, but maybe the tests don't pass because they want the results in a different order? Here goes: function inventory(curInv, newInv) { // accumulate not found var accumulator = []; // iterate over current inventory for (var count = 0; count < newInv.length; count++) { var obj = newInv[count]; var quantity = obj[0]; var item = obj[1]; // search for item in current inventory var found = false; for (var counter = 0; counter < curInv.length; counter++) { if (curInv[counter][1] === item) { found = counter; } } if (found !== false) { curInv[found][0] = curInv[found][0] + quantity; } else { // push onto accumulator accumulator.push(obj); } } // from accumulator, push to curInv for (var aCounter = 0; aCounter < accumulator.length; aCounter++) { curInv.push(accumulator[aCounter]); } return curInv; } Let me try that again function inventory(curInv, newInv) { // accumulate not found var accumulator = []; // iterate over current inventory for (var count = 0; count < newInv.length; count++) { var obj = newInv[count]; var quantity = obj[0]; var item = obj[1]; // search for item in current inventory var found = false; for (var counter = 0; counter < curInv.length; counter++) { if (curInv[counter][1] === item) { found = counter; } } if (found !== false) { curInv[found][0] = curInv[found][0] + quantity; } else { // push onto accumulator accumulator.push(obj); } } // from accumulator, push to curInv for (var aCounter = 0; aCounter < accumulator.length; aCounter++) { curInv.push(accumulator[aCounter]); } return curInv; } Steven Leiva @StevenXL Jun 22 2015 22:04 ah - how silly of me It says to add the new items in alphabetical order. Steven Leiva @StevenXL Jun 22 2015 22:17 Glah! Finally got it Note to self. The integer 0 evaluates to true in JavaScript. Also, read the format of the output. That could have saved me about 1.5 hrs of work. ;-) Logan Tegman @ltegman Jun 22 2015 22:19 Haha, yeah, the truthy and falsey values of javascript can get you into real trouble it you aren't looking out for them XD Steven Leiva @StevenXL Jun 22 2015 22:20 0 evaluates to false!! LOL. I still need to learn how to use sort uses the return of a function (i.e, what does 1 vs -1 mean), etc. But that was a good exercise. Learned a bit. Pretty self-explanatory though: gabazine @gabazine Jun 22 2015 22:25 what does the first section constitutes as in the above sentence "Go to http://www.codecademy.com/courses/web-beginner-en-bay3D/0/1 and complete the first section."? is it 1 of 13 or 1 to 13 Logan Tegman @ltegman Jun 22 2015 22:26 1 to 13 gabazine @gabazine Jun 22 2015 22:26 kk tnks Candis Wasell @CandiW Jun 22 2015 22:28 Hi - I'm having a little issue with the Bonfire Title Case a Sentence - my code returns the 'I'm a little tea pot' string just fine, but errors on the other strings passed in. Could someone take a look and see if there's something I could fix? function titleCase(str) { var words = str.split(' '); var results = []; for (var i=0; i < words.length; i++) { var letter = words[i].charAt(0).toUpperCase(); results.push(letter + words[i].slice(1)); } return results.join(' '); } titleCase("I'm a little tea pot"); Sorry - I'm used to slack chat - not sure how to make the code more readable? Logan Tegman @ltegman Jun 22 2015 22:29 Gotta put the  on the line above and below your code. It's quite picky. Candis Wasell @CandiW Jun 22 2015 22:29 This message was deleted Let me try -  function titleCase(str) { var words = str.split(' '); var results = []; for (var i=0; i < words.length; i++) { var letter = words[i].charAt(0).toUpperCase(); results.push(letter + words[i].slice(1)); } return results.join(' '); } titleCase("I'm a little tea pot");  Michael Krebs @michael-krebs Jun 22 2015 22:30 var words = str.split(' '); var results = []; for (var i=0; i < words.length; i++) { var letter = words[i].charAt(0).toUpperCase(); results.push(letter + words[i].slice(1)); } return results.join(' '); } titleCase("I'm a little tea pot"); Krzysztof Miąsko @kmiasko Jun 22 2015 22:30 code only, line need to start with  Michael Krebs @michael-krebs Jun 22 2015 22:31 You need the  to be on it's own line or it gets mad @CandiW You're only changing the first character of each word. You have to change each other character in the word to be lowercase Krzysztof Miąsko @kmiasko Jun 22 2015 22:33 @CandiW lowercase the rest oh :) kk, need some rest, good night ppl Michael Krebs @michael-krebs Jun 22 2015 22:34 I beat you :P night @CandiW try using str.substr()maybe :) Candis Wasell @CandiW Jun 22 2015 22:41 ok - I'll give that a try - thanks Tom DeFrank @TomDeFrank Jun 22 2015 22:43 Candi you can add two slices together as well: like : string = string.slice(0,1) + string.slice(2) that would actually cut out index '1' but you get the idea :) willamgriffin @willamgriffin Jun 22 2015 23:01 anybody feel like giving me a hand with bonfire : truncate string? nm just need to get rid of and equal sign and truncate only to 8 chars Candis Wasell @CandiW Jun 22 2015 23:31 Thanks to everyone for the help! Solved the bonfire :) ar2g @ar2g Jun 22 2015 23:34 @AdventureBear haven't had a chance yet... I'll give it another go tomorrow. Adam Rehard @adamrehard Jun 22 2015 23:43 I've got a stupid question. I just started jQuery, and I'm not sure how far to go on Codecademy. Do I finish the lesson there, or stop at a certian point before the end of the lesson? *certain Lightwaves @Lightwaves Jun 22 2015 23:45 go through all 3 then you check completed through the jquery section of fcc Adam Rehard @adamrehard Jun 22 2015 23:46 Gotcha. Thanks! Lightwaves @Lightwaves Jun 22 2015 23:47 I just finished jquery, was pretty cool. First experience with javascript. enjoying it but little habits from like c# or java are creeping in like I would do this.somefunction(); instead of$(this).somefunction();
and I'd wonder why it wasn't working
haha