These are chat archives for FreeCodeCamp/Help

22nd
Jan 2015
Cristián Berríos
@crisberrios
Jan 22 2015 01:52 UTC
Hello World!
Gregory Scheerlinck
@greg-js
Jan 22 2015 02:06 UTC
@lan3jur Cool beans man, I live in the UK now but I'm from Aalst (aka Oilsjt ajoin). good luck with the challenges :)
Darryl Dixon - Piece Digital
@piecedigital
Jan 22 2015 02:12 UTC
@cristian-berrios Greetings! Welcome to FCC!
Cristián Berríos
@crisberrios
Jan 22 2015 02:14 UTC
@piecedigital thanks! Joined 2 days ago but just joined /help and /letspair, hoping I can help others and maybe doing some pairing :)
Ryan Malm
@Rybar
Jan 22 2015 05:22 UTC
anyone have experience animating with jquery + velocity? Need some help.
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:39 UTC
@Rybar not but it sounds interesting
I am wondering why adding a jquery statement at the top of my JS file halts the page loading??
James McShane
@jmcshane
Jan 22 2015 05:41 UTC
where is the script called in the HTML file compared to jQuery?
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:41 UTC
ummm...
it's an event handler, here...
I'm trying to convert this from jvaascript to jquery
so far the ONLY change I've made is to add the initial jquery statement:
$("#temperature").on("click", switchunits);
in the top of the JS file. Next I was going to comment out the inline JS in the HTML.
but as soon as I added the line above, it won't load. It may not be a big deal, I just didn't expect it to break the page...
Ben Clist
@BenClist
Jan 22 2015 05:43 UTC
Does Codepen include jquery for you?
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:43 UTC
yes, you have to select it, but I did and it's there
James McShane
@jmcshane
Jan 22 2015 05:44 UTC
what if you surround that in a
$(document).ready( function() {

});
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:44 UTC
lemme try.
James McShane
@jmcshane
Jan 22 2015 05:44 UTC
it may be trying to reference the object with id temperature before it is loaded
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:44 UTC
you mean the entire JS file or just the jquery?
OH
hmm
YES! that worked!
you guys are smart
James McShane
@jmcshane
Jan 22 2015 05:45 UTC
woot!
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:45 UTC
so much to learn...the learning curve is huge!
James McShane
@jmcshane
Jan 22 2015 05:45 UTC
key point here: be careful with jQuery. Stuff might not exist yet
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:45 UTC
so why isn't that hte case with plain JS?
i couldn't figure out why there wasn't a similar statement for the JS
James McShane
@jmcshane
Jan 22 2015 05:47 UTC
good question
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:48 UTC
OK, well now my page is loading but the link doesn't work anymore, lol.
Ryan Malm
@Rybar
Jan 22 2015 05:49 UTC
@AdventureBear, couple of things: first, `$("#temperature").on("click", switchUnits());
$("#temperature").on("click", switchUnits());
check your dev console for javascript errors when things suddenly stop working, gives good clues. ;)
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:50 UTC
OK, great suggestion!
Ryan Malm
@Rybar
Jan 22 2015 05:51 UTC
add that line to the end of the JS and it works as expected, now that units is defined. http://codepen.io/Rybar/pen/vEmwVY
that's slick btw.
James McShane
@jmcshane
Jan 22 2015 05:52 UTC
If you had a little more access to the HTML, you should put the reference to the JS script at the bottom of the file
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:52 UTC
thanks, I used a tutorial, but having a lot of fun playing with it. It keeps me entertained as I go.
Ben Clist
@BenClist
Jan 22 2015 05:52 UTC
Didn't know you could post Codepen direct to the chat
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:53 UTC
I htink that's new
Ben Clist
@BenClist
Jan 22 2015 05:53 UTC
That's really cool
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:53 UTC
@jmcshane I'm not sure what you mean? I just took the JS out of the HTML to put it into jquery. I don't know what's best I'm just trying to get comfortable manipulating stuff.
btw here is the original one that won't break while i play with this one
Ryan Malm
@Rybar
Jan 22 2015 05:56 UTC
@AdventureBear He's talking about where the script loads in the DOM, not really applicable to a codepen. @jmcshane by default codepen loads your custom js last.
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:56 UTC
ah
James McShane
@jmcshane
Jan 22 2015 05:56 UTC
ah, ic
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:56 UTC
are you guys seeing a place local to you?
Ryan Malm
@Rybar
Jan 22 2015 05:57 UTC
Nope, Chalco
James McShane
@jmcshane
Jan 22 2015 05:57 UTC
there is a little canada about 20 miles from me
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:57 UTC
haow far is that from you?
Ben Clist
@BenClist
Jan 22 2015 05:57 UTC
Mine is about 15km out
James McShane
@jmcshane
Jan 22 2015 05:57 UTC
i was going to ask if you lived north of st paul
Suzanne Atkinson
@AdventureBear
Jan 22 2015 05:57 UTC
mine's about 3 miles away from me "Lincoln Place". little township I've never heard of. I had to look it up!
James McShane
@jmcshane
Jan 22 2015 05:57 UTC
yeah, 15 km is probably about right
Ben Clist
@BenClist
Jan 22 2015 05:57 UTC
And also in the jQuery the temperature is definitely way out
the jQuery version*
Ryan Malm
@Rybar
Jan 22 2015 05:59 UTC
Oh I guess it is close.
Sarpy county... little southeast of me
James McShane
@jmcshane
Jan 22 2015 06:00 UTC
mine's a little northeast
Ryan Malm
@Rybar
Jan 22 2015 06:00 UTC
Can you feed it a specific zipcode?
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:01 UTC
no that's one of the modifications the tutorial suggested trying out .
that's part of why I want to convert it to jquery, so that's something I can do easier.
Ryan Malm
@Rybar
Jan 22 2015 06:02 UTC
well jquery is really just dom manipulation, "Get and Do"... the do() is typically vanilla JS.
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:03 UTC
i guess I feel more comfortable "getting" things using jquery?
I only know as much as I've learned through FCC and the challenges here.
So looking at this codepen, there's a lot of DOM changes in the JS...worth practicing to convert that to Jquery?
James McShane
@jmcshane
Jan 22 2015 06:04 UTC
@AdventureBear I felt the same way, but I just found this resource http://youmightnotneedjquery.com/ I'm still working through it, but it looks interesting
Ryan Malm
@Rybar
Jan 22 2015 06:04 UTC
I understand, but you'll definitely need to step outside your comfort zone here, there isn't going to be any converting to jQuery once you've started dealign with ajax calls/JSON requests for dynamic data
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:04 UTC
now I"m really confused!
James McShane
@jmcshane
Jan 22 2015 06:04 UTC
ah, lots of info all at once
sorry, that can happen in a chat like this
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:05 UTC
just yesterday someone pasted a "youmightneedjqueryif" link
James McShane
@jmcshane
Jan 22 2015 06:05 UTC
haha, whoops
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:05 UTC
for the API call specifically
James McShane
@jmcshane
Jan 22 2015 06:05 UTC
oi
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:05 UTC
lol
Ryan Malm
@Rybar
Jan 22 2015 06:05 UTC
sorry. What I'm saying is, Once you've converted the bits that manipulate what you see on screen, you're still left with all the code that does the dirty work of getting the weather data
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:05 UTC
i gues sgetting comfortable with what it can make easier and what's just excess?
James McShane
@jmcshane
Jan 22 2015 06:07 UTC
yes, getting comfortable with jquery is a good thing. I may be putting the cart before the horse a bit
or at least confusing the cart with the horse
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:07 UTC
haah
yep I can see that
OK, so should I tackle this in jquery?
function getLocationAndWeather()
@Rybar yeah I can see your point too. So would that JS code still go between the document. ready call ? I thought a function could hang out anywhere and then it's just called when needed. But I may be confusing old C programming
James McShane
@jmcshane
Jan 22 2015 06:09 UTC
maybe start with the function loadBackground, that seems like a good one to start with
the location and weather one seems like the last one i would do
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:10 UTC
OK, great, that's exactly what I need, just a push toward the next thing to try.
:)
James McShane
@jmcshane
Jan 22 2015 06:10 UTC
good luck!
Ryan Malm
@Rybar
Jan 22 2015 06:10 UTC
:) when did they add in-line codepen to gitter? That's Super-cool.
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:11 UTC
cool!
Ben Clist
@BenClist
Jan 22 2015 06:11 UTC
it's bloody amazing
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:11 UTC
a little seizure inducing but cool!
Ben Clist
@BenClist
Jan 22 2015 06:11 UTC
Nice animation :)
Ryan Malm
@Rybar
Jan 22 2015 06:12 UTC
thanks. :D
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:13 UTC
should this go inside the docuemnt ready tags since i"ll be doing it in jquery
function loadBackground
Ryan Malm
@Rybar
Jan 22 2015 06:13 UTC
I just discovered this: http://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage which is in use on ALOT of codepens, going to go back to a couple of my fun ones and add sliders and fiddleknobs
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:20 UTC
that's the box on the right to adjust things?
Ryan Malm
@Rybar
Jan 22 2015 06:25 UTC
yes
Cristián Berríos
@crisberrios
Jan 22 2015 06:25 UTC
LPT: always copy the code to clipboard before submitting to Coderbyte :/
Ryan Malm
@Rybar
Jan 22 2015 06:25 UTC
so you can easily attach sliders and checkboxes to variables in your code
@cristian-berrios :( that's always a bummer.. we had that happen during pairing twice
during the live session
Cristián Berríos
@crisberrios
Jan 22 2015 06:28 UTC
:(
well, I'm still on easy, I could remember the whole function, but it would be a big one in longer programs
Ryan Malm
@Rybar
Jan 22 2015 06:38 UTC
ok guys, nearly 1am here. goodnight!
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:42 UTC
data.photos
Object {page: 1, pages: 4, perpage: 250, total: "771", photo: Array[250]}
goodnight!
Anyone know why I can only see 1 page of results, even though it says there are four pages?
data.photos.page = 1
Ben Clist
@BenClist
Jan 22 2015 06:47 UTC
according to the flickr api bounding box queries will only return 250 photos
to prevent too much load on the databse
I guess
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:48 UTC
that makes sense...were did you find that? I looked here
Ben Clist
@BenClist
Jan 22 2015 06:48 UTC
on that same page
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:48 UTC
boundin box being lat/long?
Ben Clist
@BenClist
Jan 22 2015 06:48 UTC
ctrl + f bbox
you could try lat, long and radius?
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:50 UTC
I see. But I'm using lat, long, sort, accuracy & relevance
I thought about trying radius
what's happening is that I return a random photo by checking data.photos.total
but it looks like if there are more than 1 page of results and say the random number is 400 (should be on page 2), then I get a undefined error and a gray background
I shall sleep on it and try again tomorro1
Thanks for your help, @BenClist
Ben Clist
@BenClist
Jan 22 2015 06:52 UTC
hmm, not sure then. A quick fix would be to limit the random to 250
so if random > 250 random = 250
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:52 UTC
right that makes me sad though. :( all those amazing photos just left off.
I'd need a little logic to limit it to 250 OR total if total < 250
NM
I just use a different varaible
data.photos.photo.length
instead of
data.photos.total
Ben Clist
@BenClist
Jan 22 2015 06:56 UTC
there you go :)
Suzanne Atkinson
@AdventureBear
Jan 22 2015 06:57 UTC
:)

OH, and I found this: "lat (Optional)
A valid latitude, in decimal format, for doing radial geo queries.

Geo queries require some sort of limiting agent in order to prevent the database from crying. This is basically like the check against "parameterless searches" for queries without a geo component."

so even though it's not a bbox, it's the same limitation
sweet.
Well I didn't do what I wanted but I made forward progress in my coding prowess. That sometimes gray background was really bugging me.
you guys helped me figure it out by suggesting the console whenever something doesn't work!
Yay
Ben Clist
@BenClist
Jan 22 2015 06:59 UTC
Great to see the progress, having little projects like this to work on is definitely the best way to learn
Suzanne Atkinson
@AdventureBear
Jan 22 2015 07:06 UTC
thanks @BenClist ! super satisfying.
good night
Ben Clist
@BenClist
Jan 22 2015 07:07 UTC
night @AdventureBear
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 13:05 UTC
@wdgreg haha coolness!! How’s life over there? I live quite close to Oilsjt :)
Gregory Scheerlinck
@greg-js
Jan 22 2015 13:42 UTC
@lan3jur Hah it's nice here but I miss the fries and the mexicanos and the durums. I gain quite a bit of weight every time I go back to visit :)
Florian Beijers
@zersiax
Jan 22 2015 13:57 UTC
<!DOCTYPE html>
<head>
<script src="/assets/jquery.js"></script>
<style>
</style>
</head>

<body>
<div class="prompt"></div>

<script>
var prompts = [
         'Type your name', 
         'Type an adjective',
         'Type a noun'
    ];


    // alert(prompts.length);
    // alert(prompts[0]);
// jQuery to insert an array-indexed item into the empty HTML div
    $('.prompt').html(prompts[0]);
    </script>
</body>
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 13:58 UTC
@wdgreg haha .. Are you living there for your job?
Ah @zersiax ! I passed that challenge with no issues
seahik
@seahik
Jan 22 2015 13:58 UTC
@zersiax which challenge is this again?
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 13:59 UTC
@zersiax try removing the comments and see what happens?
Florian Beijers
@zersiax
Jan 22 2015 14:00 UTC
project five, section 1 checkpoint 6 :) @lan3jur the comments are required by the checkpoint :)
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:00 UTC
ah yes.. forgot :)
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:00 UTC
I moved here with my girlfriend. Working part time from home now (freelance writing) but hoping to transition into something that pays better :)
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:00 UTC
try adding a tab before //jQuery and removing the tab before </script>?
Just guessing here..
Florian Beijers
@zersiax
Jan 22 2015 14:01 UTC
it will be something very small ...something like the functions being in the wrong order, or a different kind of quote ...it's finicky that way
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:01 UTC
but it must be a detail like that
@wdgreg cool!! What are you writing for / about?
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:02 UTC
Well the only thing that you may recognize is express.be but I quit there a few months ago to focus on studying, apart from that I do translations and copy writing for a bunch of websites
seahik
@seahik
Jan 22 2015 14:03 UTC
This message was deleted
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:03 UTC
Ah sweet!! Might come in handy for me some day ;-)
seahik
@seahik
Jan 22 2015 14:04 UTC
oh wait that is for the next checkpoint nevermind
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:05 UTC
@zersiax try cleaning your indentations ..
They seem to be strict about that
like with javascript: function () {} fails but function() {} passes
Florian Beijers
@zersiax
Jan 22 2015 14:05 UTC
i might have found it ...just a sec
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:07 UTC
@wdgreg do you also translate from Swedish to English? :)
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:08 UTC
Ha! no, french, dutch, spanish and german to english but no swedish :)
seahik
@seahik
Jan 22 2015 14:08 UTC
oh i didn't know youre swedish @wdgreg ?
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:08 UTC
No I'm flemish, but I do admit i look a typical swede
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:08 UTC
Well, back to coding.. laters :)
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:09 UTC
happy coding :)
Florian Beijers
@zersiax
Jan 22 2015 14:09 UTC
nope, I was wrong :) Ithought maybe copying from Firefox into notePad++ left some nbsp's in there, js and PHP interpreters trip on that ...but that wasn't it. and cleaning up the indents wasn't it either
seahik
@seahik
Jan 22 2015 14:09 UTC
ah ok I wonder where lan got swedish?
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:09 UTC
@zersiax so that code isn't doing anything? no errors in the console?
Florian Beijers
@zersiax
Jan 22 2015 14:10 UTC
If I really try I understand one or two swedish words out of 10 since I know Dutch but ...its tough :)
seahik
@seahik
Jan 22 2015 14:10 UTC
here is my code which looks just like yours except for indents and different comments
<!DOCTYPE html>

<head>
<script src="/assets/jquery.js"></script>
<style>
</style>
</head>

<body>
<div class="prompt"></div>
<script>
  var prompts = [
    'Type your name',
    'Type an adjective',
    'Type a noun'
  ];
  // insert prompt into html
  $('.prompt').html(prompts[0]);
//alert(prompts.length);
//alert(prompts[0]);
</script>
</body>
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:10 UTC
Heh yeah, danish is much easier to understand I find
just something about the pronounciation
seahik
@seahik
Jan 22 2015 14:11 UTC
oh wow, i've heard the opposite, but I live in Sweden so I'm probably just getting one side of the story
they joke that even Danish people say they can't understand each other
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:11 UTC
I have a crush on a Swedish girl ;-)
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:11 UTC
Well I'm just basing it on my having watched a bunch of scandinavian movies and tv shows and I tend to understand danish considerably better :)
Ghost
@ghost~54bf7177db8155e6700ee568
Jan 22 2015 14:11 UTC
just saying :P
seahik
@seahik
Jan 22 2015 14:12 UTC
Danish sound muffled to me, like if you have marbles in your mouth.
Florian Beijers
@zersiax
Jan 22 2015 14:13 UTC
this really is bizarre , pasting in your code works fine
Florian Beijers
@zersiax
Jan 22 2015 14:14 UTC
shrug ...my code was syntactically sound so I'll just continue on now I guess :)
seahik
@seahik
Jan 22 2015 14:15 UTC
darn! yes just press on.. You understand it that's most important!
Florian Beijers
@zersiax
Jan 22 2015 14:17 UTC
ok ...moving back to main. I don't get notifies about things so if you need me ping me on there or in a PM because I likely won't be monitoring here all that much :)
seahik
@seahik
Jan 22 2015 14:18 UTC
yep good luck...sorry coudn't figure it out
Ben Stoltz
@benstoltz
Jan 22 2015 14:18 UTC
was that in dash or in code school?
Oh dash. I had some problems with it being overly strict/not taking valid responses. usually I could fenangle it by switching browsers or adjusting spacing. Was silly.
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:21 UTC
+1 for 'fenangle'
Julie Myers
@BlueOceanView
Jan 22 2015 14:30 UTC
If anyone needs to learn AJAX, teamtreehouse.com has a really good class on it.
Ben Stoltz
@benstoltz
Jan 22 2015 14:34 UTC
Yesssss Fenangle :)
Anthony Albertorio
@tesla809
Jan 22 2015 14:39 UTC
Hello
Ben Stoltz
@benstoltz
Jan 22 2015 14:39 UTC
olleH
Anthony Albertorio
@tesla809
Jan 22 2015 14:39 UTC
I am stuck on this coderbyte problem for a minute now
... more than a minute, like a day
any help is appreciated

'''
//Coderbyte Problem 4 Easy- Letter Challenge
// still need to fix
// 1- finding ampersands in regular expression
// I can hack it with an if statement, but that's sloppy

// 2- special characters are shifting too,
// I want to exit that iteration of the for loop
// and add the special character in question to the new
// array

// 3- refactoring obviously

function main(){
// start
console.log("Enter string");
var str = prompt(" ");

// final output
console.log(LetterChanges(str));

}

function LetterChanges(str){
var strArray = str.split("");
var strNewArray = [];

for(var i = 0; i < strArray.length; i++) {
    if (strArray[i].match(/[^\w]+/g) === true){
        strNewArray.push(strArray[i]);
        break;
    } else if (strArray[i] === " ") {
        strNewArray.push(" ");
        continue;
    } else {
        var character = strArray[i].charCodeAt(0);
        character += 1;
        character.toString();
        character1 = String.fromCharCode(character);
        strNewArray.push(character1);
    }
}

    return strNewArray.join("");

}

main();

'''

'''
//Coderbyte Problem 4 Easy- Letter Challenge
// still need to fix
// 1- finding ampersands in regular expression
// I can hack it with an if statement, but that's sloppy

// 2- special characters are shifting too,
// I want to exit that iteration of the for loop
// and add the special character in question to the new
// array

// 3- refactoring obviously

function main(){
// start
console.log("Enter string");
var str = prompt(" ");

// final output
console.log(LetterChanges(str));

}

function LetterChanges(str){
var strArray = str.split("");
var strNewArray = [];

for(var i = 0; i < strArray.length; i++) {
    if (strArray[i].match(/[^\w]+/g) === true){
        strNewArray.push(strArray[i]);
        break;
    } else if (strArray[i] === " ") {
        strNewArray.push(" ");
        continue;
    } else {
        var character = strArray[i].charCodeAt(0);
        character += 1;
        character.toString();
        character1 = String.fromCharCode(character);
        strNewArray.push(character1);
    }
}
    return strNewArray.join("");       

}
main();
'''

jeez my formatting is off sorry guys
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:42 UTC
First thing I can see is that you're calling your main function outside of the letterchanges function
and .match doesn't return false or true, it returns an array with the matches
what you're looking for is /regex/.test(stringToTest)
Anthony Albertorio
@tesla809
Jan 22 2015 14:43 UTC
ummm I think thats it
can you give me an example?
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:43 UTC
/a/.test('a'); // true
/a/.test('b'); // false
Also, your control flow is a bit off. you don't need the break; in your if statement nor the continue
Anthony Albertorio
@tesla809
Jan 22 2015 14:45 UTC
These are all good suggestions
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:45 UTC
if your first if statement evaluates as true, it will execute that code and skip the else if and else
you can use break and continue for breaking out of loops though
Anthony Albertorio
@tesla809
Jan 22 2015 14:46 UTC
aaa thats right
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:46 UTC
but can you tell me what the code is supposed to do though? not sure what the question is :)
is this the one to capitalize vowels?
Anthony Albertorio
@tesla809
Jan 22 2015 14:46 UTC
ooo sorry i didn't explain
it does this:
Using the JavaScript language, have the function LetterChanges(str) take the str parameter being passed and modify it using the following algorithm:
Replace every letter in the string with the letter following it in the
alphabet (ie. c becomes d, z becomes a). Then capitalize every vowel in this new string (a, e, i, o, u) and finally return this modified string.
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:47 UTC
Ah yes
Anthony Albertorio
@tesla809
Jan 22 2015 14:47 UTC
its the 4th challenge in coderbyte
so the shifting is working
but, it is shifting everything including the punctuation
I am trying to find a .match or a filter or something to skip the punctuation and just push it into the new array
but ... its not working haha
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:48 UTC
What I'd recommend is to start over from scratch but this time start with this:
```
str = str.split('').map(function(char){
// your code here
}
oops forgot the final backticks ;)
Anthony Albertorio
@tesla809
Jan 22 2015 14:48 UTC
aaa can you explain the .map function?
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:48 UTC
Sure, so str.split('') will give you an array of all the characters, right
Anthony Albertorio
@tesla809
Jan 22 2015 14:48 UTC
yup
got that part
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:48 UTC
and map then calls a function on each of those characters
Anthony Albertorio
@tesla809
Jan 22 2015 14:49 UTC
how is it different than the .filter function
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:49 UTC

so for example:

[1,2,3].map(function(num){
  return num + 5;
});

this will return [6,7,8]

Anthony Albertorio
@tesla809
Jan 22 2015 14:50 UTC
so it creates a new array based on the output of the function
?
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:50 UTC
yes
Anthony Albertorio
@tesla809
Jan 22 2015 14:50 UTC
ok that makes sense, so I wont need to create a second array before the for loop
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:50 UTC
So you can use if statements inside that function to check whether each character is a letter or a number or a space or whatever and then process it as required
Anthony Albertorio
@tesla809
Jan 22 2015 14:51 UTC
aaaa that cleans up things a bit
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:51 UTC
Yes, you can do it your way too, but this will save you some headaches because it's much easier to look at
Anthony Albertorio
@tesla809
Jan 22 2015 14:51 UTC
i agree with your way however, mine was a rough hack
is there a short hand way for a regex for only punctuation?
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:52 UTC
But either way, the thing with the character codes is still going to feel hacky :) but i think you'll be able to solve it this way
Hmm, I don't think so (but I'm not sure) but you can test for 'not a letter'
Anthony Albertorio
@tesla809
Jan 22 2015 14:53 UTC
how so? that seems to be the most straight forward way to do it
I appreciate the help so far! I am going to take your suggestions and re do the code
shchoi22
@shchoi22
Jan 22 2015 14:55 UTC
just to provide variety to the conversation, I actually used String.charCodeAt(0) to shift
Anthony Albertorio
@tesla809
Jan 22 2015 14:55 UTC
Its always good to have a second pair of eyes on things
shchoi22
@shchoi22
Jan 22 2015 14:55 UTC
instead of regex
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:56 UTC
The character codes? yeah it is the most straightforward way, but it just looks so weird incrementing character codes with seemingly random numbers that's all :)
shchoi22
@shchoi22
Jan 22 2015 14:57 UTC
i am used to solving encoding problems with ASCII and UTF-8 encodings when using web APIs so it wasn't too hard for me
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:57 UTC
How so, @shchoi22 ? you tested whether the charcode of characters fall in a certain interval?
shchoi22
@shchoi22
Jan 22 2015 14:57 UTC
yep
Anthony Albertorio
@tesla809
Jan 22 2015 14:57 UTC
yea same here @shchoi22 , thought i did
'''
var character = strArray[i].charCodeAt(0);
character += 1;
character.toString();
character1 = String.fromCharCode(character);
strNewArray.push(character1)
'''
though*
shchoi22
@shchoi22
Jan 22 2015 14:58 UTC
remember charCodeAt() is case sensitive
Gregory Scheerlinck
@greg-js
Jan 22 2015 14:58 UTC
@shchoi22 Well that works too. i prefer regex though :)
Anthony Albertorio
@tesla809
Jan 22 2015 14:58 UTC
@shchoi22 how did you get past the issues with not shifting the punctuation though?
shchoi22
@shchoi22
Jan 22 2015 14:58 UTC
i believe the charcode for lowercase a-z is from 96 to 120ish
so testing that and having separate if for z to shift back to a is all you need
Anthony Albertorio
@tesla809
Jan 22 2015 14:59 UTC
so anything that is not 96 to 120 was not shifted then
shchoi22
@shchoi22
Jan 22 2015 14:59 UTC
yes
Anthony Albertorio
@tesla809
Jan 22 2015 14:59 UTC
aaa man thanks for the idea
this makes things soooooooo much simpler
My ideas was to use regex to filter out all punctuation, and what ever was left to run thru algo in an if else statement
shchoi22
@shchoi22
Jan 22 2015 15:01 UTC
but I do suggest practicing regex when you can. im sure @wdgreg knows this but you'll use regex far more than character codes.
Anthony Albertorio
@tesla809
Jan 22 2015 15:01 UTC
any good resources for it?
regex is kicking my ass man
shchoi22
@shchoi22
Jan 22 2015 15:01 UTC
the problem is with that is you need to get the punctuation back after you shift which is a hard task on its own
Anthony Albertorio
@tesla809
Jan 22 2015 15:01 UTC
yea thats exactly the part that I am stuck on haha
the shift part was straight forward
shchoi22
@shchoi22
Jan 22 2015 15:02 UTC
i think FCC's source for regex is a bit light but the practice session should cover 80~90% of what you face out in the world
Anthony Albertorio
@tesla809
Jan 22 2015 15:02 UTC
aaa, is that where you picked it up?
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:03 UTC
Yeah the FCC regex source is decent. it doesn't mention backreferences or lookaheads but you can get by without those for now (but learn them later though)
shchoi22
@shchoi22
Jan 22 2015 15:03 UTC
i read a book :smile:
it was required for my job
Jason Rueckert
@jsonify
Jan 22 2015 15:03 UTC
Anthony Albertorio
@tesla809
Jan 22 2015 15:04 UTC
aaa man, thanks @phlacin
Jason Rueckert
@jsonify
Jan 22 2015 15:05 UTC
or www.regex101.com is also another one to test with, but not as intuitive, i feel
Anthony Albertorio
@tesla809
Jan 22 2015 15:06 UTC
will check out both of them
the first one seem more intuitive, you are right @phlacin
yea this is exactly what I needed. Thanks @phlacin
Jason Rueckert
@jsonify
Jan 22 2015 15:09 UTC

@tesla809 awesome. There's a RegEx joke:

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

Anthony Albertorio
@tesla809
Jan 22 2015 15:10 UTC
LOL
HAHA, I'm am laughing out loud now because that is exactly what I was thinking just a few minutes ago @phlacin
the problem is now more about learning regex than the problem itself
Jason Rueckert
@jsonify
Jan 22 2015 15:13 UTC
yeah, but if you just keep using it...or trying your best...you'll eventually memorize the major parts that you find yourself using all the time
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:15 UTC
Yeah, regex looks crazy at first but it quickly becomes almost second nature
Julie Myers
@BlueOceanView
Jan 22 2015 15:23 UTC
Is regex used a lot in the real world?
Anthony Albertorio
@tesla809
Jan 22 2015 15:24 UTC
regex is starting to grow on me
question, how do i refactor this?
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:24 UTC
Yes, it's used all the time
And not just in JS, but in pretty much every other programming language too and on the command line and in certain text editors
Anthony Albertorio
@tesla809
Jan 22 2015 15:24 UTC
'''
if (/(\W)/g.test(strArray[i]) === true || /([0-9])/g.test(strArray[i]) === true){
// some code
}
'''
"""
if (/(\W)/g.test(strArray[i]) === true || /([0-9])/g.test(strArray[i]) === true){
// some code
}
"""
jeez why doesn't the markdown work for me
' ' '
var markdown = "markdown";
' ' '
... nope whats the deal
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:25 UTC
@tesla809 You don't need the round parentheses there, those are for capturing groups (like for example when you're matching several regexes in a string)
Adam Hollett
@admhlt
Jan 22 2015 15:25 UTC
@tesla809 , use the backtick (`) which shares a key with ~ on most keyboards
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:25 UTC
You need to use backticks ` instead of apostrophes
Anthony Albertorio
@tesla809
Jan 22 2015 15:26 UTC
ooo haha thanks @admhlt
Adam Hollett
@admhlt
Jan 22 2015 15:26 UTC
It's an underdog key. Very rarely used :)
Anthony Albertorio
@tesla809
Jan 22 2015 15:26 UTC
if (/(\W)/g.test(strArray[i]) === true || /([0-9])/g.test(strArray[i]) === true){
            // some code
        }
yea I have actually never noticed it until now, haha
@wdgreg what do you mean?
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:27 UTC
If you change /(\W)/g into /\W/g nothing will change
also, you don't need the g flag in this case either, you're only matching a single character after all
*testing, not matching
Anthony Albertorio
@tesla809
Jan 22 2015 15:29 UTC
aaa i will try it out. thanks @wdgreg
can I combine the two or statements into one regex expression
I have been trying, but it is messing up the \W part
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:30 UTC
Using () is for capturing groups, which is very useful, but not for testing a regex against a string. it's used extensively for matching and replacing though
You could use /[a-zA-Z]/ for matching any kind of letter, very easy to see what it means
eh testing! I keep saying matching :)
and /[\W0-9]/.test(str) === true is equivalent to what you wrote
or /[\W\d]/
Gregory Scheerlinck
@greg-js
Jan 22 2015 15:35 UTC
I think I used /[^a-z]/ in my solution for this challenge, but I kept a boolean for uppercase
Anthony Albertorio
@tesla809
Jan 22 2015 15:41 UTC
Let me try that out
It seems like a more straight forward way to write the code.
Nathan
@terakilobyte
Jan 22 2015 15:42 UTC
/[a-z]/i is a bit shorter if you're only interesting in matching the alphabet
www.regex101.com should be in your bookmarks if you are using regex
Julie Myers
@BlueOceanView
Jan 22 2015 15:44 UTC
@wdgreg Thanks.
Christopher Hutchinson
@cshutchinson
Jan 22 2015 17:45 UTC
it seems array addition must be the biggest challenge of the easy coderbytes
makes me even more dang determined now
Gregory Scheerlinck
@greg-js
Jan 22 2015 17:49 UTC
Yeah that's definitely the hardest one. most of the medium challenges are much easier
still haven't figured it out myself :)
Christopher Hutchinson
@cshutchinson
Jan 22 2015 17:50 UTC
I am on it now until i finish wish me luck
my coding skills are improving rapidly doing these
Gregory Scheerlinck
@greg-js
Jan 22 2015 17:52 UTC
Great :) good luck!
Margie
@gladcoding
Jan 22 2015 19:12 UTC
Don't mind me. I just want to test how to post a line of code
<button class="flash">Exit</button>
Cristián Berríos
@crisberrios
Jan 22 2015 19:14 UTC
sure, np
Margie
@gladcoding
Jan 22 2015 19:17 UTC
ok if I have no regular text and key in three back tics it automatically shift key boards to enter code
blah blah blah shift enter
code here
ok enough I got it ;-)
Justin Rogers
@yaskyj
Jan 22 2015 19:22 UTC
You can also press Ctrl + / to switch to compose mode. Then you wouldn't need to worry about Shift + Enter.
Margie
@gladcoding
Jan 22 2015 19:23 UTC
@yaskyj great I added to my shortcuts Thxs
Ryan Malm
@Rybar
Jan 22 2015 20:26 UTC
so I'd like to see this rotate in place when hitting the white button. any css transition gurus in the room?
won't work inline; not enough space and no resize code yet
Margie
@gladcoding
Jan 22 2015 20:52 UTC
in older to rotate, isn’t suppose to be position: relative?
Ryan Malm
@Rybar
Jan 22 2015 22:08 UTC
nah, it rotates, just not around it's "center".
I want the div "contents" to rotate around its center. The inline version doesn't work because the window is too small; open it in a new window/tab to see