These are chat archives for codefellows/sea-c16-javascript

16th
Jul 2014
Scott Romney Burbidge
@sburbidg
Jul 16 2014 00:04
hmm, that was working yesterday
This message was deleted
whatever, ignore the html.
So my problem here is that the last element in store isn't getting popped.
Scott Romney Burbidge
@sburbidg
Jul 16 2014 00:09
I can't figure out why. Any ideas?
Tyler Morgan
@toastynerd
Jul 16 2014 00:11
well first, that’s really tough to read, it should look like this:https://gist.github.com/toastynerd/88aaf18f1556fa60c9b1
except for that t on line 2 that I can’t get rid of for some reason..
also, I’ll give you a hint: you don’t need two for loops
if you hit a delimiter you sould add the word to the return array and reset the word to empty string
Kristoffer Hebert
@hirekris
Jul 16 2014 00:24

(function () {
'use strict';

function Add(x, y) {
    return x + y;
}
function countDecorator(func) {
    var newfunc = function (x, y) {
        newfunc.add();
        return func(x, y);
    };
    newfunc.count = 0;
    newfunc.callCount = function () {
        return this.count;
    };
    newfunc.add = function () {
        newfunc.count++;
    };
    return newfunc;
}

}());

Scott Romney Burbidge
@sburbidg
Jul 16 2014 00:24
I'll give that a look. JSbin does not like to let me format stuff correctly. I'll double check next time.
Kristoffer Hebert
@hirekris
Jul 16 2014 00:25
is there a way to do this without passing arguments like x and y. This would help with reusability with any function
Tyler Morgan
@toastynerd
Jul 16 2014 00:28
yeah, use the arguments keyword that I posted the docs for
Tyler Morgan
@toastynerd
Jul 16 2014 00:35
var newfunc = function() {
  newfunc.add();
  return func(arguments);
}
Kristoffer Hebert
@hirekris
Jul 16 2014 00:38
Lol, is there a reason why it works with only on parameter of arguments for the two parameters for x, y
Tyler Morgan
@toastynerd
Jul 16 2014 00:42
well that should give you NaN but in general Javascript doesn’t enforce airity (the number of arguments in a function) its up to the programmer to make sure it’s being used correctly
or do you mean how does arguments represent both x and y?
in which case the answer is: because it’s an array and all that happens in the Javascript internals when you add arguments to a function is they get added to the arguments array.
Kristoffer Hebert
@hirekris
Jul 16 2014 00:48
return func(arguments[0], arguments[1]);
Tyler Morgan
@toastynerd
Jul 16 2014 00:48
yeah, that works as well
Kristoffer Hebert
@hirekris
Jul 16 2014 00:52
arguments.forEach(function(){})
whoops
Tyler Morgan
@toastynerd
Jul 16 2014 00:52
lol, nevermind, mine doesn’t work you have to do arguments[0], arguements[1]
Tyler Morgan
@toastynerd
Jul 16 2014 00:58
ahh, that’s what I forgot, you have to use the apply method https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
var newfunc = function() {
  newfunc.add();
  return func.apply(this, arguments);
}
Joe Elsey
@joeelsey
Jul 16 2014 01:09
Does Chrome support regular expressions from javascript?
Tyler Morgan
@toastynerd
Jul 16 2014 01:16
@joeelsey Yeah, I’m pretty sure it’s part of the standard, so almost all modern day javascript engines should support it.
Joe Elsey
@joeelsey
Jul 16 2014 01:20
Ok. I'm probably doing something wrong then because it seems like they aren't working how they should. Thanks.
Kristoffer Hebert
@hirekris
Jul 16 2014 04:24
Anyone apply and hear back for the JS full-stack accelerator?
Larry Scroggins
@lwscroggins
Jul 16 2014 04:38
@hirekris I've applied but haven't heard back.
Kristoffer Hebert
@hirekris
Jul 16 2014 04:57
Ok, just wanted to make sure I wasn't the only one.
Tyler Morgan
@toastynerd
Jul 16 2014 06:01
Just a quick announcement, I’m substitute teaching Hank’s section tomorrow and all my examples and demonstrations are going to be using node. I will also give a very brief introduction to node. So, if you want to follow along, install node http://nodejs.org/ I can also help with installs during lab time but they do have easy installers for most platforms. You can also find it using apt-get(just make sure to get nodejs and not node) on Ubuntu or Debian machines and Homebrew on OSX if you have it.
Aron Garavaglia
@agaravag
Jul 16 2014 06:12
Hi everyone! Is there a trick to getting lodash to work with sublime text and chrome?
Hank Yates
@hankyates
Jul 16 2014 16:49
@agaravag in chrome if you visit the lodash website and open a console it is available
Jeff Battema
@thewocky
Jul 16 2014 16:50
The link to Required Reading for tonight's class has the inner html and href reversed. http://joelhooks.com/blog/2014/02/06/stop-writing-for-loops-start-using-underscorejs/
Tyler Morgan
@toastynerd
Jul 16 2014 16:50
you have to include it in a script tag in your html or copy and paste the library into your dev console;
Hank Yates
@hankyates
Jul 16 2014 16:53
@thewocky DOH
@hirekris you are pretty close there
Jeff Battema
@thewocky
Jul 16 2014 17:07
So--lodash is basically underscore on steroids. It has all the same methods as underscore, plus more. Yes?
Tyler Morgan
@toastynerd
Jul 16 2014 17:11
@thewocky pretty much, it’s also faster(they spend a lot of time optimizing for different browsers)
Jeff Battema
@thewocky
Jul 16 2014 17:31
lodash : objects :: jquery : DOM elements
Ivan Storck
@ivanoats
Jul 16 2014 18:09
Installing Node, I highly recommend NVM via Homebrew, if you already have homebrew for Mac. Node Version Manager (NVM) is easy to keep up to date, doesn’t require sudo to install npm packages, and allows you to test the most recent versions of node.
brew install nvm
and homebrew is at http://brew.sh - intsall instructions at bottom of page
I will be T.A.ing for Martin tonight and will also answer questions about the dev accelerators
Joaquin Guardado
@macikokoro
Jul 16 2014 19:30
@ivanoats that will be great, I'm sure a lot of us have questions
Joe Elsey
@joeelsey
Jul 16 2014 20:03
Still trying to figure out the delimiter homework without the split(). I can filter out the '$' as a string or an array, but I haven't found a way to return each section into an array the same way the split() is able to. Any hints?
Joaquin Guardado
@macikokoro
Jul 16 2014 20:03
@joeelsey I'm in the same boat
@joeelsey Maybe drinking some coffee would help :)
Jeff Battema
@thewocky
Jul 16 2014 20:13
@joeelsey @macikokoro Strings have a length property that you can iterate through just like an array. So one approach is to check each letter in the string to see if it matches the separator. Strings also have indexOf() and lastIndexOf() methods, which return the index of the supplied argument.
Joaquin Guardado
@macikokoro
Jul 16 2014 20:13
@joeelsey Did you try looking at for loops and iterating
@thewocky Thanks Jeff !
@joeelsey I'm using codecademy labs as a sandbox. This could also help
Nicholas Weber
@NEWeber
Jul 16 2014 20:34
@toastynerd Thanks for grabbing my water bottle!
Tyler Morgan
@toastynerd
Jul 16 2014 20:39
@NEWeber Yeah, it was the small nalgene right?
Nicholas Weber
@NEWeber
Jul 16 2014 20:39
@toastynerd Yep, the REI one with the insulation sleeve.
Tyler Morgan
@toastynerd
Jul 16 2014 20:40
cool, it’s in the kitchen by the mircowave
Nicholas Weber
@NEWeber
Jul 16 2014 20:41
@toastynerd Great! Where's the kitchen? (I can just ask tonight too.)
Tyler Morgan
@toastynerd
Jul 16 2014 20:41
It’s just past the couches in the easy
Nicholas Weber
@NEWeber
Jul 16 2014 20:42
Thanks
Tyler Morgan
@toastynerd
Jul 16 2014 20:42
np
Joe Elsey
@joeelsey
Jul 16 2014 21:09
Yep. I've looped and iterated both as a string and as an array. Looping through the string gives you the character of the string and looping through the array gives you the position of the character in the array. Best results so far have been looping through the string and pushing characters into an array. But this way I get an array position for each character instead of how it looks in the homework example. I looked at indexOf, but I could only get indexOf to give me the position of the first '$' when iterating over the length.
BrockBeaudry
@BrockBeaudry
Jul 16 2014 21:26
@joeelsey Another option would be to concatenate the character to a string, rather than push each individual character into an array. If you want more of an explanation let me know.
Jeff Battema
@thewocky
Jul 16 2014 21:46
@joeelsey ...or instead of dealing with one character at a time, grab the set of characters between separators using substr() or substring().
Ivan Storck
@ivanoats
Jul 16 2014 21:59
interesting JS story about our Dev Accelerator. Upvote for our mind-controlled quadcopter story please?! http://www.reddit.com/r/javascript/comments/2aw8xf/student_project_harnesses_brain_power_via/
CTownsdin
@CTownsdin
Jul 16 2014 22:14
JSFiddle.net is a nice JS sandbox
press JSHint at the top and it will find pesky syntax errors for you too
Joaquin Guardado
@macikokoro
Jul 16 2014 22:36
Does anyone know if we can use charAt() for the homework?
Joe Elsey
@joeelsey
Jul 16 2014 22:37
@thewocky I tried substr() and substring() and couldn't figure it out. @BrockBeaudry I'll see what I can do with concatenating. I haven't really tried that yet.
Ivan Storck
@ivanoats
Jul 16 2014 22:46
@toastynerd are you in the building?
jbassage
@jbassage
Jul 16 2014 23:20
@Ctownsdin Hey thanks, I was looking for something like that
Tyler Morgan
@toastynerd
Jul 16 2014 23:21
@macikokoro don’t use charAt() just do []
Joaquin Guardado
@macikokoro
Jul 16 2014 23:22
@toastynerd any reason in particular?