These are chat archives for FreeCodeCamp/Help

8th
Jan 2015
Sean May
@Lumiras
Jan 08 2015 01:07
Need some help on the jquery exercises if anyone has a moment
actually, turns out I figured it out on my own. False alarm :)
Quincy Larson
@QuincyLarson
Jan 08 2015 02:00
@Lumiras Great! Enjoy!
Suzanne Atkinson
@AdventureBear
Jan 08 2015 03:54
heyall
var james = {
    job: "programmer",
    married: false
};

// set to the first property name of "james"
var aProperty = "job";

// print the value of the first property of "james" 
// using the variable "aProperty"

console.log ( james[aProperty]);
Branden Byers
@brandenbyers
Jan 08 2015 03:54
hi
Suzanne Atkinson
@AdventureBear
Jan 08 2015 03:54
Working on javascript in codecademy
challenge intro to objects ii
Ben Stoltz
@benstoltz
Jan 08 2015 03:55
well you’re creating a james object initially
you access object methods with a .
Suzanne Atkinson
@AdventureBear
Jan 08 2015 03:55

31 in FCC (cash register). The code above "should" work to print james' job to the consle, but its not.

Ben Stoltz
@benstoltz
Jan 08 2015 03:55
so your variable would actually be var aProperty = ames.job;
james*
Suzanne Atkinson
@AdventureBear
Jan 08 2015 03:55
whoa...sorry about the bold!
Ben Stoltz
@benstoltz
Jan 08 2015 03:56
And then you can just console.log the variable aProperty
Suzanne Atkinson
@AdventureBear
Jan 08 2015 03:56
that makes sense but that's not what the exercise wants I don't think.
instructions:

Take advantage of the ability to use variables with bracket notation.

In line 7, set aProperty to a string of the first property in james (ie. the job property).

Then print james's job using bracket notation and aProperty.

so the aProperty is just supposed to be the property, then calling that varaible within bracket notation.
Ben Stoltz
@benstoltz
Jan 08 2015 03:57
…okay….
that’s weird but okay
in that case
it would be: var aProperty = james[“job”];
Suzanne Atkinson
@AdventureBear
Jan 08 2015 03:58
lol...well I figure it has something to do with the next part of the exercise. Maybe the fill an array with property names or something, and loop through the object that way? I don't know, but I don't like moving on if there is something I"m doing incorrectly. It just looks like that should work.
Ben Stoltz
@benstoltz
Jan 08 2015 03:59
Maybe try:
var james = {
    job: "programmer",
    married: false
};

// set to the first property name of "james"
var aProperty = james["job"];

// print the value of the first property of "james"
// using the variable "aProperty"

console.log (aProperty);
Suzanne Atkinson
@AdventureBear
Jan 08 2015 04:01
well I ran my orginal code in codepen and it worked the way i thought it would. it didn't like your solution either so I'll just move on. Thanks for the help!
Ben Stoltz
@benstoltz
Jan 08 2015 04:01
lol okay
Evan Davis
@davisec52
Jan 08 2015 04:24
@AdventureBear I just ran your code in the display at labs.codecademy.com and it worked there without problem. I know you've moved on, but . . .
Dominic Jones
@towwiow
Jan 08 2015 04:35
@AdventureBear sometimes with these tutorial sites, I've found you have to refresh for the code to take. It's annoying but 'eh. What can you do?
Suzanne Atkinson
@AdventureBear
Jan 08 2015 05:05
thanks guys for the reassurance!
i moved on but may not get the "badge" if I don't have all them officiall completed, lol
Bin Ury
@teddy-error
Jan 08 2015 05:06
Why is using the find method in jquery faster than just selecting ?
Bin Ury
@teddy-error
Jan 08 2015 05:14
I mean, as opposed to like using psuedoselecters for instance
what is the advantage of $(#dogs li:first); vs $(#dogs li).first() ??
Branden Byers
@brandenbyers
Jan 08 2015 05:16
The context selector is converted to find. Not sure how much faster it really is or isn't.
Bin Ury
@teddy-error
Jan 08 2015 05:17
:worried:
As you are looking through your code, you notice that someone else is selecting the last vacation with: $("#vacations li:last"). You look at this and you think, "Traversal would make this way faster!" You should act on those thoughts, refactor this code to find the last li within #vacations using traversal instead.
-Code School
Branden Byers
@brandenbyers
Jan 08 2015 05:24
As far as I understand it, this use to be more of a concern than it is now.
If you want to read more on it on the jQuery website, I just found a link that should help you: http://learn.jquery.com/performance/optimize-selectors/
Bin Ury
@teddy-error
Jan 08 2015 05:26
thank you. I will definitely review docs (eventually no doubt) I'm just following the FCC course and I didn't want to be blindly swallowing ideas without understanding them
Branden Byers
@brandenbyers
Jan 08 2015 05:26
Selector optimization is less important than it used to be, as more browsers implement document.querySelectorAll() and the burden of selection shifts from jQuery to the browser.
It's a good question. I agree with not blindly going through. I wouldn't worry about it too much. Following that advice is still good.
Quincy Larson
@QuincyLarson
Jan 08 2015 06:50
My advice is drink from the fire hose. It will make sense later - the 10th time you do it it'll click.
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 07:24
@QuincyLarson what did you mean about the non-profit matcher?
Quincy Larson
@QuincyLarson
Jan 08 2015 07:27
12 code campers have completed all the challenges and easy/medium Coderbyte problems. We're helping them choose nonprofit projects to build.
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 07:42
oh
Bin Ury
@teddy-error
Jan 08 2015 11:56
So, in javascript, I'm inferring that when you pass a function as a parameter without any arguments (omitting the parenthesis) it's passed as an object, and when you pass it with arguments it is passed as its return value
Is that on/near the :moneybag: ?
Evan Davis
@davisec52
Jan 08 2015 12:55

While searching for help with a coderbyte problem, I found this code:

function LetterChanges(str) {
    return str.replace(/[a-zA-Z]/g, function(c){
        return String.fromCharCode(c.charCodeAt(0)+1);
    }).replace(/[aeiou]/g, function(c){
        return c.toUpperCase();
    });
}
LetterChanges("pizzaro");

This code produces an error with the letter "z." My question, though, is what is function(c)? I dont' understand the parameter.

Maxim Orlov
@Maximization
Jan 08 2015 12:58
it's a higher-order function
Evan Davis
@davisec52
Jan 08 2015 12:59
What does that mean?
Maxim Orlov
@Maximization
Jan 08 2015 12:59
instead of passing an argument to a function you can pass in another function and let that function return an argument
Nathan
@terakilobyte
Jan 08 2015 12:59
very very common in js
Evan Davis
@davisec52
Jan 08 2015 12:59
Is "c" the argument that is returned by the function?
Nathan
@terakilobyte
Jan 08 2015 12:59
and one of the things that makes it so awesome
Evan Davis
@davisec52
Jan 08 2015 13:00
That is, does the function return an arg to itself?
@terakilobyte Yes, I can feel the awesomeness. Tell me more, please.
Nathan
@terakilobyte
Jan 08 2015 13:01
@davisec52 c is jus the iterator, so to speak
Nathan
@terakilobyte
Jan 08 2015 13:01
that’s saying c is the element in question to those functions
Evan Davis
@davisec52
Jan 08 2015 13:01
In the example above, what would 'c' signify?
@Maximization thank you1
Maxim Orlov
@Maximization
Jan 08 2015 13:01
the match!
/[a-zA-Z]/g
Nathan
@terakilobyte
Jan 08 2015 13:01
so if I have a world “hello”, and I do something like ”hello”.map(function(c) {… c will be every ltter in hello
now
Maxim Orlov
@Maximization
Jan 08 2015 13:02
so the letter that has been matched
Nathan
@terakilobyte
Jan 08 2015 13:02
that algorithm is broken
in the code you posted
you said it breaks on z, do you know why?
Evan Davis
@davisec52
Jan 08 2015 13:02
@Maximization @terakilobyte Becoming clearer. Thank you!
Not exactly. I can see that it does not seem to be advance z to a.
Nathan
@terakilobyte
Jan 08 2015 13:03
right. So the way to do that is by using the modulo operator
%
Evan Davis
@davisec52
Jan 08 2015 13:03
I'm not sure how to correct it, though
Maxim Orlov
@Maximization
Jan 08 2015 13:03
what happens when you pull out the charcode of z then add it by 1?
Evan Davis
@davisec52
Jan 08 2015 13:04
@Maximization That should advance z to a. I'm not sure how to add that code, though.
Nathan
@terakilobyte
Jan 08 2015 13:04
consider the following: 1 % 26 === 1, 26 % 26 === 0, 27 % 26 === 1
Maxim Orlov
@Maximization
Jan 08 2015 13:04
what @terakilobyte said, by using the modulo
Nathan
@terakilobyte
Jan 08 2015 13:04
the problem with the way their code is, they can’t effectively wrap around
you always want to start under what you are going to use as your wrapping value (modulo value)
Evan Davis
@davisec52
Jan 08 2015 13:05
@terakilobyte Thank you.
Nathan
@terakilobyte
Jan 08 2015 13:05
ascii character codes for letters are 65-whatever for uppercase and 97-whatever for lowercase
but, here’s a question
if I have the letter z
Evan Davis
@davisec52
Jan 08 2015 13:06
Sorry to do this. I've got to get to an eye exam and still have to take a shower. Wash off the sludge. Thank you again. I'll be back!
Nathan
@terakilobyte
Jan 08 2015 13:06
let’s say it’s ascii code (charCode) is 122
if I add one to that and use % 26 what do I get?
ah take care!
damn, I was just getting to the good part
@Maximization sorry, I should have let you get that, my bad for barging in
Maxim Orlov
@Maximization
Jan 08 2015 13:07
123 % 26 = 19 so (device control 3)
ha!
Nathan
@terakilobyte
Jan 08 2015 13:08
lol
exactly, I was about to reveal the trick, to subtract A or a, rotate the letter, modulo, then add A or a
and finally link the wikipedia article no the caesar cipher
Maxim Orlov
@Maximization
Jan 08 2015 13:08
yeah, standard pattern for this kind of stuff
Nathan
@terakilobyte
Jan 08 2015 13:09
yep
rot26 is still the best encryption there is imo
Maxim Orlov
@Maximization
Jan 08 2015 13:09
practice some ciphering problems and it's going to be muscle memory
Nathan
@terakilobyte
Jan 08 2015 13:09
my 2048 bit pgp key is weak compared to rot26
;)
Maxim Orlov
@Maximization
Jan 08 2015 13:10
rot26? that gets you back to the same
or is that a joke
Nathan
@terakilobyte
Jan 08 2015 13:10
yeah it’s a joke
Maximization @Maximization laughs
Maxim Orlov
@Maximization
Jan 08 2015 13:10
ok
man I'm almost done with coderbyte, 8 left
toughest ones
Using the JavaScript language, have the function OverlappingRectangles(strArr) read the strArr parameter being passed which will represent two rectangles on a Cartesian coordinate plane and will contain 8 coordinates with the first 4 making up rectangle 1 and the last 4 making up rectange 2. It will be in the following format: ["(0,0),(2,2),(2,0),(0,2),(1,0),(1,2),(6,0),(6,2)"] Your program should determine the area of the space where the two rectangles overlap, and then output the number of times this overlapping region can fit into the first rectangle. For the above example, the overlapping region makes up a rectangle of area 2, and the first rectangle (the first 4 coordinates) makes up a rectangle of area 4, so your program should output 2. The coordinates will all be integers. If there's no overlap between the two rectangles return 0.
this is what's so disturbing about coderbyte, is that instead making the problems build op on each other and starting from the basics you get thrown into the deep like that
Nathan
@terakilobyte
Jan 08 2015 13:14
yeah they aren’t organized well at all
Maxim Orlov
@Maximization
Jan 08 2015 13:14
why not have a problem first that asks you to calculate an area, then build on from that
Nathan
@terakilobyte
Jan 08 2015 13:14
well
I’ve talked to quincy about making a replacement for coderbyte on fcc
Maxim Orlov
@Maximization
Jan 08 2015 13:15
+1!
Nathan
@terakilobyte
Jan 08 2015 13:15
that steals from coderbyte, code abbey, and codewars
I mean borrows, since they are all open source
Maxim Orlov
@Maximization
Jan 08 2015 13:15
oh that would be great
you could have a separate curriculum as part of challenge#34 which has like 60 small problems
and all link to one of the sites
starting from beginner and building up on difficulty
Nathan
@terakilobyte
Jan 08 2015 13:18
yep
Maxim Orlov
@Maximization
Jan 08 2015 13:18
same principle as the FCC main curriculum, small tasks that can be completed in a session
Nathan
@terakilobyte
Jan 08 2015 13:18
it will take a while
Maxim Orlov
@Maximization
Jan 08 2015 13:18
if you want to record videos for every one of them, yyes
Nathan
@terakilobyte
Jan 08 2015 13:18
oh hell no
Maxim Orlov
@Maximization
Jan 08 2015 13:19
but other than that it shouldn't take more than a couple of days
Nathan
@terakilobyte
Jan 08 2015 13:19
but actually coming up with the challenges and the validations and errors (and hints to go with errors)
Maxim Orlov
@Maximization
Jan 08 2015 13:20
1: build the curriculum
2: create small pages with link for each one of them
and done
oh you want people to be coding on FCC's site
that's another scale of complexity
you don't have to though
current FCC doesn't have any own exercises at all besides the jQuery ones
and I'm sure codewars, coderbyte or codeabbey won't mind the publicity
Nathan
@terakilobyte
Jan 08 2015 13:23
@QuincyLarson wants them on fcc
it’s actually not that hard, I don’t think
codepen was built with http://codemirror.net/
there’s a tutorial showing how they did it
Maxim Orlov
@Maximization
Jan 08 2015 13:26
I'm sure it's doable, but it will take some time for sure
and you'll need more than one guy to do it
Nathan
@terakilobyte
Jan 08 2015 13:26
yep
seahik
@seahik
Jan 08 2015 13:44
great ideas...I like the idea of building on skills
Ben Stoltz
@benstoltz
Jan 08 2015 13:45
Morning.
seahik
@seahik
Jan 08 2015 13:47
i have only tried CB, codewars and codeabbey. I liked Codeabbey the best as it had an educational intro and the problems started easy and got harder. Felt like something doable that you wanted to continue.
hey ya Ben
Ben Stoltz
@benstoltz
Jan 08 2015 13:49
For me when I started out in dev I sorta jumped into the deep end. I hadn’t coded before three years ago, took my first two programming classes (a python clsas and an intro to web dev class) and by the end of the semester I was tutoring the entire web dev major. Did that for two years years. So now I’m much better at analyzing other peoples code and mistakes/fixing them then I am at writing/conceptualizing my own code. It’s weird.
I’ve been considering trying to write a book, or at least a blog….I kinda feel like it would bridge that gap
Maxim Orlov
@Maximization
Jan 08 2015 13:53
I think it's normal in the same way that psychologists can diagnose other people and fail to do the same on themselves
Ben Stoltz
@benstoltz
Jan 08 2015 13:55
Yeah @Maximization, but it’s so darn annoying. I can look at someone elses code and go “Hmmm yeah that’s why it’s broken” pretty quick, but then go Derppppp when I try to work in on starting algorithms or data structures.
Ultimately…..I suppose it more has to do with I’m used to reading code rather then writing it.
Nathan
@terakilobyte
Jan 08 2015 13:55
@benstoltz just comes with practice
Maxim Orlov
@Maximization
Jan 08 2015 13:55
yeah, two completely different skillsets
Nathan
@terakilobyte
Jan 08 2015 13:56
I started the other way around, and didn’t look at other people’s code at all
but I got to the point where I’d think about my own code and walk through it like a computer would
so when I look at someone else’s code it takes me a minute because the first thing that gets me is “why did you name this that” or “why did you go about it that way"
rather than finding the error
Maxim Orlov
@Maximization
Jan 08 2015 13:57
^
personally I feel debugging other people's codes is much more difficult
Nathan
@terakilobyte
Jan 08 2015 13:58
yeah
Maxim Orlov
@Maximization
Jan 08 2015 13:58
it's trying to positionate into the code's author and understand his thinking pattern
Nathan
@terakilobyte
Jan 08 2015 13:58
I don’t know their variable names or the strategy they had
Maxim Orlov
@Maximization
Jan 08 2015 13:58
that means putting aside your own
Nathan
@terakilobyte
Jan 08 2015 13:58
so it’s hard to see the flaw in the strategy
Ben Stoltz
@benstoltz
Jan 08 2015 14:00
The biggest thing that annoys me about other peoples code is space around operators for some reason. If I see frank=blah god it annoys me. Or 1+2. I like it 1 + 2
Maxim Orlov
@Maximization
Jan 08 2015 14:03
oh yeah I am very picky when it comes to coding formatting
Nathan
@terakilobyte
Jan 08 2015 14:04
I write compactly
and let the beautifyer fix it
but it depends
this is how I’d write something simple...
Maxim Orlov
@Maximization
Jan 08 2015 14:06
when it's not my code I neglect it, but when it is mine I make sure every little formatting is consistent throughout the whole document, whitespace/brackets/newlines/varnames/expressions etc.
Nathan
@terakilobyte
Jan 08 2015 14:07
var cubes = [1,2,3].map(function(num) {
  return Math.pow(num,3);
});
return cube[0] + cube[1] + cube[2];
Maxim Orlov
@Maximization
Jan 08 2015 14:07
as soon as something's off I have to fix, otherwise it's going to hang in my head and bother me
I tend to write arrays like this [1, 2, 3]
with spaces after the commas
Nathan
@terakilobyte
Jan 08 2015 14:07
yeah, I just never have
oh, one thing I’ll never write..
Maxim Orlov
@Maximization
Jan 08 2015 14:07
num, 3 too
always space after commas, guess it's what you're used to
Nathan
@terakilobyte
Jan 08 2015 14:08
if (true) return true;
// or
if (true) {return true;}
Maxim Orlov
@Maximization
Jan 08 2015 14:09
the second one is horrible
Nathan
@terakilobyte
Jan 08 2015 14:09
it must be
if (true) {
  return true;
}
Maxim Orlov
@Maximization
Jan 08 2015 14:09
although I don't mind the first one, use it regularly for short if statements I know they will stay at one line
Nathan
@terakilobyte
Jan 08 2015 14:09
if I get someone else’s code and they have returns like the first example I will change them to my style
big big fan of following a unified style
it shouldn’t matter if it’s long or short, same style imo
if it’s a simple assignment or return based on a condition, use a ternary for brevity :P
Maxim Orlov
@Maximization
Jan 08 2015 14:11
yeah, it would be wrong to switch from one to another half way your document
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:12
can anyone help me complete this code: change the paragraph's solid black backgrounds color to a semi-transparent linear gradient. it should begin as solid black at the bottom, and end as 40% black at the top
Maxim Orlov
@Maximization
Jan 08 2015 14:12
ternaries are great
Nathan
@terakilobyte
Jan 08 2015 14:12
@rrashbull I’d love to help. Please post the code you have so far
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:12
background: rgba(0,0,0,1);
this is the code but i cant fix to be as its been asked
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 14:13
dont forget your vendor prefixes
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:13
its a paragraph background color
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 14:13
remember -webkit- and -moz-?
right but for gradients
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:14
i am new at coding i just started today
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 14:14
no problem!
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:14
and i dont know much about them :)
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 14:14
you’re on the right track with transparency, that 4th digit in rgba controls that
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:14
yes but how to make it half transparency
with 40% at the top of the paragraph
Nathan
@terakilobyte
Jan 08 2015 14:15
have you experimented?
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:15
yes
but i cant fix
yqyeoh
@yqyeoh
Jan 08 2015 14:16
testing
Ben Stoltz
@benstoltz
Jan 08 2015 14:16
gnitset
Ryan Malm
@Rybar
Jan 08 2015 14:16
the a in rgba is expressed as a decimal between 0 and 1.
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:16
yes but there is not a solid color
Nathan
@terakilobyte
Jan 08 2015 14:17
?
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:17
the test its asking me to mage a paragraph like this: p {
color: rgba(255,255,255,1);
background: rgba(0,0,0,1);
padding: 10px;
line-height: 28px;
text-align: justify;
position: absolute;
bottom: 0;
margin: 0;
}
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 14:17
@rrashbull Look at slide 35
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:18
and they ask to be like this at the end the background color
change the paragraph's solid black backgrounds color to a semi-transparent linear gradient. it should begin as solid black at the bottom, and end as 40% black at the top
Nathan
@terakilobyte
Jan 08 2015 14:18
right
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:18
@terakilobyte the problem is how to do it
Ryan Malm
@Rybar
Jan 08 2015 14:18
so you need to look up syntax for a gradient, because simply changing background-color won't do it
Nathan
@terakilobyte
Jan 08 2015 14:18
so the difference would be rgba(0,0,0,1) and rgba(0,0,0,.4)
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:18
as much as i've ben learned til yet just to crease a singe color with rgba
Nathan
@terakilobyte
Jan 08 2015 14:19
the rest is googling ‘css gradient'
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:20
@terakilobyte i try the code you've sent but even that works
can you please tell me how exacly should be writted
background: rgba(0,0,0,1) rgba(0,0,0,.4) or?
yqyeoh
@yqyeoh
Jan 08 2015 14:23
var code="formatted"
#123
var code="formatted"
hmm? how do i format the codes in the chatbox?
Ryan Malm
@Rybar
Jan 08 2015 14:27
@rrashbull You'll learn far more googling 'css gradient' than asking for a specific line of code. but I'll throw you a bone: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_gradients
@yqyeoh type 3 backticks: " ``` " and then enter.
then your code, then ctrl-enter.
yqyeoh
@yqyeoh
Jan 08 2015 14:28
var code = "formatted"
ah! magical
thanks!
Tomy Lim
@Nocando
Jan 08 2015 14:28
Good morning everyone
Ryan Malm
@Rybar
Jan 08 2015 14:29
good morning!
yqyeoh
@yqyeoh
Jan 08 2015 14:29
i've a question on the jquery exercise #7
http://www.freecodecamp.com/jquery-exercises
when i typed
```
$("#location1 input").attr("checked", true)
both checkboxes are checked
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 14:30
morning @Nocando!
yqyeoh
@yqyeoh
Jan 08 2015 14:30
then i unchecked by typing
Kreshnik Qungeli
@rrashbull
Jan 08 2015 14:30
@Rybar thnx i'll try
yqyeoh
@yqyeoh
Jan 08 2015 14:31
$("#location1 input").attr("checked", false)
then both checkboxes were unchecked as expected
but when i tried to check them again using the same method i did previously
$("#location1 input").attr("checked", true)
nothing happens, although from the html, i can see that both checked attributes are checked
anyone has any idea?
Ryan Malm
@Rybar
Jan 08 2015 14:51
someone else ran into that same problem, jquery bug? try .prop or .removeAttr
stackOverflow says use .prop

turns out, not a bug. from the stackoverflow answers:

There is a difference between an attribute and a property of an element. The attribute is the initial state, and the property is the current state.

You are setting the attribute of the options, which only works when the element doesn't have the attribute to begin with. After that the property takes over and setting the attribute has no effect on the current state any more.

Alex Hazel
@metalhaze
Jan 08 2015 14:57
:+1:
Ryan Malm
@Rybar
Jan 08 2015 15:01
@yqyeoh ^
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 15:50
Anyone here for a little help?
Ben Stoltz
@benstoltz
Jan 08 2015 15:50
What’s up @AmmarAliShah?
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 15:51
wait i'll post the code
Adam Hollett
@admhlt
Jan 08 2015 15:51
I'm here too
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 15:51
<div id="tour">
  <h2>Paris, France Tour</h2>
  <p>$2,499 for 7 Nights</p>
  <button>See photos from our last tour</button>
  <ul class="photos">
    <li>
      <img src="/assets/photos/paris1.jpg">
      <span>Arc de Triomphe</span>
    </li>
    <li>
      <img src="/assets/photos/paris2.jpg">
      <span>The Eiffel Tower</span>
    </li>
    <li>
      <img src="/assets/photos/paris3.jpg">
      <span>Notre Dame de Paris</span>
    </li>
  </ul>
</div>
$(document).ready(function() { 
  $("#tour").on("click", "button", function() {
    $(this).closest('#tour').find('.photos').slideDown();
  });
});
Can you guys find the problem?
Adam Hollett
@admhlt
Jan 08 2015 15:52
What's supposed to happen, and what behaviour are you getting?
Supposed to show photos when you click on the tour's show photos button, right?
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 15:54
yes
here's the link to the challenge ^
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 15:58
so you only have one tour ID there right?
I don’t think you have to find the closest one, for one thing
Adam Hollett
@admhlt
Jan 08 2015 15:58
Your code works fine. CodeSchool for some reason wants you to write a function that shows ALL .photos elements.
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 15:59
@admhlt yeah my code does work
Adam Hollett
@admhlt
Jan 08 2015 15:59
Your code is better in a real use situation, but for some reason the lesson wants that
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 15:59
@admhlt okay thanks for the help
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 16:00
I would try not to paste in the answer in /help
more direct someone in how to think about a problem
Adam Hollett
@admhlt
Jan 08 2015 16:00
good point, ty
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 16:01
@figitalboy but my code was fine
Michael D. Johnson
@CodeNonprofit
Jan 08 2015 16:01
but @AmmarAliShah is a pretty good programmer so you’re not going to cheat him as much as someone else who might just take the answer and run without understanding it
your code looked like overkill to me when you had one tour ID, but I am not an expert
Ammar Ali Shah
@AmmarAliShah
Jan 08 2015 16:02
@figitalboy thanks
Ryan Malm
@Rybar
Jan 08 2015 17:04
to check for semantic-ness, is there an easy way to turn off all CSS in the devtools?
Ryan Malm
@Rybar
Jan 08 2015 17:17
Evan Davis
@davisec52
Jan 08 2015 18:51

@terakilobyte @Maximization and anyone else who would like to offer some javascript help:

This morning I was trying to sort out the coderbyte LetterChange function. In order to better understand the process, I tried to split a function I found on stackexchange and created a kind of Frankenstein function. However, I still can't get z to shift to a. You were trying to explain that to me when I had to take off to a Dr. appt. I thought I could just "brute force it" by changing the ascii code to from 122 to 97, but that didn't work.

function LetterChanges(str) {
    var x = str.replace(/[a-zA-Z]/g, function(c){
        return String.fromCharCode(c.charCodeAt(0)+1);
    });
    x = x.replace(/[aeiou]/g, function(c){
        return c.toUpperCase();
    });
    for(var i = 0; i < x.length; i++) {
        if(x.charCodeAt[i] === 122) {
            x[i] = String.fromCharCode(x.charCodeAt(97));
        }
    }
    return x;
}
LetterChanges("hotdoggiez");
Angelica Ferdinand
@ESOComputing
Jan 08 2015 19:05
I want to setup a linux dual boot on my windows 7 laptop, anyone here have a recommended method to set up Ubuntu with Windows 7?
Maxim Orlov
@Maximization
Jan 08 2015 19:09
@davisec52 hey there, welcome back
so, getting from z to a, the solution is a mathematical one
think in terms of unicode, what's the range of a to z and how do you make sure it doesn't go beyond z
it involves using the modulo operator, as we said before
and in order to be able to do that you would have to first convert to a zero-base unicode, apply the modulo, then convert back to get the appropriate letter
Evan Davis
@davisec52
Jan 08 2015 19:13
@Maximization Thank you for coming back--right, you were trying to explain how modulo was the key.
123 % 26 = 4.7
Maxim Orlov
@Maximization
Jan 08 2015 19:14
exactly, so that won't work
why do we use 26? 26 letters in the alphabet of course
z = 26
Evan Davis
@davisec52
Jan 08 2015 19:15
That I understand, I just don't get what we are doing with modulo
Maxim Orlov
@Maximization
Jan 08 2015 19:15
when we add one to z we want to get back to a right?
Evan Davis
@davisec52
Jan 08 2015 19:16
right
Maxim Orlov
@Maximization
Jan 08 2015 19:16
let's assume the following 0,1,2,3....25 = a,b,c,d....z
Evan Davis
@davisec52
Jan 08 2015 19:16
right
Maxim Orlov
@Maximization
Jan 08 2015 19:17
we give all leters an index, if we have z=25 and we want to shift by 3 that gives us 28
Evan Davis
@davisec52
Jan 08 2015 19:17
I considered making two arrays
one of the alphabet and one of numbers
Maxim Orlov
@Maximization
Jan 08 2015 19:18
what modulo does, by giving us the remainder it makes sure the number will never exceed the module
you cannot have a remainder which is greater than the modulo
so 26 + 3 % 26 = 3 which is in turn equal to c
Evan Davis
@davisec52
Jan 08 2015 19:19
where does 3 come from?
Maxim Orlov
@Maximization
Jan 08 2015 19:19
it's easier than that, you have unicode at your disposal, you don't have to renumber the letters
29 % 26 = 3
you know how the modulo works?
Evan Davis
@davisec52
Jan 08 2015 19:20
Just what I picked up on Codecademy. I don't understand where you got 3.
Ben Stoltz
@benstoltz
Jan 08 2015 19:21
@Maximization He means the shifting the 26 over by three
Not the remainder 3
Maxim Orlov
@Maximization
Jan 08 2015 19:21
oh right
Evan Davis
@davisec52
Jan 08 2015 19:21
Why are you shifting 26 over by 3?
Maxim Orlov
@Maximization
Jan 08 2015 19:21
that's an arbitrary shift, it could be any number
to give an example
@davisec52 in your code, you're shifting by one
Evan Davis
@davisec52
Jan 08 2015 19:23
So we are after a modulo to give us the index of "a"?
Maxim Orlov
@Maximization
Jan 08 2015 19:23
we use the modulo to remain within the bounds of the alphabet
we don't want to go beyond z, instead we want to get back to a and continue from there
the alphabet is 26 letters long so we use modulo 26, the remainder in this case will always be less than 26
Evan Davis
@davisec52
Jan 08 2015 19:24
That makes sense, but how does this become code?
Maxim Orlov
@Maximization
Jan 08 2015 19:25
well, you know unicode right? check out this table http://www.asciitable.com/
the dec column gives you the unicode value in decimals for the corresponding character, that's what you'll be working with
Evan Davis
@davisec52
Jan 08 2015 19:27
Yes, I was looking at this earlier. I thought perhaps you could just force a solution by declaring x[i] = 97.
Maxim Orlov
@Maximization
Jan 08 2015 19:28
we can see that the the lowercase a is 97 and lowercase z is 122
Evan Davis
@davisec52
Jan 08 2015 19:28
I was wrong.
a difference of 25
Maxim Orlov
@Maximization
Jan 08 2015 19:28
obviously we can't use modulo 122, because we would get all the values between 0 and 122
exactly
we can make use of this difference, but first we need to transform the letter to its corresponding index in the alphabet
so, if a is 97 and a is the first letter in the alphabet, how do we transform the unicode value of a to get to that
Serhii Borovskyi
@serhiicss
Jan 08 2015 19:30
Hello! Can someone help with basic jQuery issue please?
Maxim Orlov
@Maximization
Jan 08 2015 19:30
@serhiicss shoot
Serhii Borovskyi
@serhiicss
Jan 08 2015 19:31
$(document).ready(function(){
  $(".navigation").on("click", function(){
    $(this).find('.navigation').remove();
});
I have a ul class navigation
and this script wont remove it
when clicked
Maxim Orlov
@Maximization
Jan 08 2015 19:32
you're already using $(this), why find it?
Serhii Borovskyi
@serhiicss
Jan 08 2015 19:32
ok, I remove find('.navigation')
still not workin
Maxim Orlov
@Maximization
Jan 08 2015 19:33
do you have a link to the exercise?
Serhii Borovskyi
@serhiicss
Jan 08 2015 19:33
it is my site Im working on
Maxim Orlov
@Maximization
Jan 08 2015 19:33
ah right, hmm
Serhii Borovskyi
@serhiicss
Jan 08 2015 19:33
let me create a jsbin quick
Maxim Orlov
@Maximization
Jan 08 2015 19:33
cool
Evan Davis
@davisec52
Jan 08 2015 19:34
@Maximization add 97 to index of a
Maxim Orlov
@Maximization
Jan 08 2015 19:34
@davisec52 in unicode a, b, c, d... z = 97, 98, 99, 100... 122 we want a, b, c...z = 0, 1, 2, ...25
opposite
Evan Davis
@davisec52
Jan 08 2015 19:35
reverse the order
Maxim Orlov
@Maximization
Jan 08 2015 19:35
instead of adding, we substract right?
a = 97 - 97 becomes a = 0
b = 98 - 97 becomes b = 1
and so on
Serhii Borovskyi
@serhiicss
Jan 08 2015 19:37
@Maximization lol. I went to jsbin, copy/paste code, saw an error and fixed. works now. Thanks!
Maxim Orlov
@Maximization
Jan 08 2015 19:37
@serhiicss haha nice, might work the next time too when you have an issue ;)
@davisec52 so we basically substract the unicode value of the first letter in the alphabet to get to 0 base index representation of a letter in the alphabet
Nathan
@terakilobyte
Jan 08 2015 19:38
I’m back from a shopping trip
Maxim Orlov
@Maximization
Jan 08 2015 19:39
did you go buy the bible books of programming?
Nathan
@terakilobyte
Jan 08 2015 19:39
imagine we want to sort some arbitrary number of kids into groups for a field trip, 3 groups to be exact
lol nope
a class has a 23 kids in the group
Evan Davis
@davisec52
Jan 08 2015 19:39
@Maximization Thank you. I'll try to work with this. I have to leave again but will be back. Thank you again!
Maxim Orlov
@Maximization
Jan 08 2015 19:40
lol @terakilobyte you get cut off again
@davisec52 no problem
Nathan
@terakilobyte
Jan 08 2015 19:40
yeah no shit :)
whatever, I’ll type it and he can stroll to read it later
@davisec52 so, 3 groups, 23 kids. 3 is our bounds, we have 3 groups. For the purposes of counting kids, or anything in CS, we start at 0.
So, the child at position 0 will go into the 1st(0) group (0 mod 3 === 0)
Child at position 1 will go into the 2nd group(1) (1 mod 3 === 1)
Child at position 2 will go to the 3rd group(2) (2 mod 3 === 2)
Nathan
@terakilobyte
Jan 08 2015 19:45
the child in position 3 will go into group 0, 4 will go to 1, 5 to 2, so on until there are no more kids
now, applying this to letters
if a is 0 and z is 25, if we add 1 to z (25 + 1) we get 26. If we take 26 mod 26 we arrive at 0. So, z becomes a
we can do this with confidence. If we add 1 to y (24 + 1) we get 25. 25 mod 26 === 25. We arrive at z, as expected
so, you have to figure out how to make 97 (ascii code for a) or 65 (ascii code for A) be 0
and more importantly, how to make sure you maintain the range of A-Z and a-z
it may seem trivial now, but being able to use the modulo operator to effectively keep some number within a range is incredibly useful
Maxim Orlov
@Maximization
Jan 08 2015 19:54
very useful, first time I encountered myself with such a problem I thought: what a pain to go through all that just so you can shift some text, but there's a whole history behind it dating back to the early civilization and the conclusive factor in WW II
it's encryption and everything that has to do with it
Nathan
@terakilobyte
Jan 08 2015 19:55
that, and buffer padding, memory management, the list goes on
Maxim Orlov
@Maximization
Jan 08 2015 19:59
those are new to me, but I can imagine it's a useful algorithm
Evan Davis
@davisec52
Jan 08 2015 20:00
@terakilobyte @Maximization I'm really sorry to keep running off. This is a weird day.
I can stick around now.
Nathan
@terakilobyte
Jan 08 2015 20:00
scroll up and read :)
Evan Davis
@davisec52
Jan 08 2015 20:00
I'm going to catch up on what you written so far. Yes, what you said!
Evan Davis
@davisec52
Jan 08 2015 20:12
@terakilobyte Read what you wrote and am going to learn more about modulo. Probably the root of my confusion.
Nathan
@terakilobyte
Jan 08 2015 20:13
@davisec52 it's very useful
Nathan
@terakilobyte
Jan 08 2015 20:57
!
!ping
Nathan
@terakilobyte
Jan 08 2015 21:04
!help
Evan Davis
@davisec52
Jan 08 2015 21:04
@terakilobyte Still alive. Sorry, I have a very limited math background. I'm doing a bit of catching up.
Nathan
@terakilobyte
Jan 08 2015 21:04
no worries
!commands
!mdn bitwise operators
Evan Davis
@davisec52
Jan 08 2015 21:08
@terakilobyte Ok, so I think I've got to the point where I actually understand how using modulo can smoothly effect the letter shift. I'm going abuse the code a bit to see if I can get a working function.
cerissa
@cerissa
Jan 08 2015 21:59
i have 2 questions, i dont want to know how to do it, as ill find that out on my own, though i might need suggestions once i start doing it, but i learn better by finding the answer myself. anyway question 1: what language would you use to make a for lack of better word app, on your webpage to show updated facebook status. i want them to actually see a picture of the facebook post. if possible.
and second question what language would i use to make it where everytime you went to the website a different text would show up just on this part. for example, im doing a website for my portfolio for a church, and every time the click on the home page or go to the web site i want a different bible quote to show up in a portion of the page
if any of that makes sense lol
lotbs
@LookOnTheBrightSide
Jan 08 2015 22:13
@cerissa javascript. look into api's also.
cerissa
@cerissa
Jan 08 2015 22:27
thanks. i apperciate it
cerissa
@cerissa
Jan 08 2015 23:08
ok one more question, what is an api and how would i use one
Nathan
@terakilobyte
Jan 08 2015 23:09
api is an abstract programming interface :)
you use one by just conforming to whatever the api author wants
if I write an api that says I’ll give you data, but you must prepend every request with the letter q and the number 7, you have to
Charles Watson
@sircharleswatson
Jan 08 2015 23:10
application program interface
:D
Nathan
@terakilobyte
Jan 08 2015 23:10
and in return I’ll give you data back
when did the definition change? I was taught abstract years ago :)
Charles Watson
@sircharleswatson
Jan 08 2015 23:10
idk but i've never heard abstract
Nathan
@terakilobyte
Jan 08 2015 23:10
hmm
either way, it remains the same. It’s just a set of protocols and function signatures they expect
Charles Watson
@sircharleswatson
Jan 08 2015 23:11
I just searched google for abstract and only results for application came up :P
cerissa
@cerissa
Jan 08 2015 23:17
hmm