These are chat archives for FreeCodeCamp/Help

2nd
Aug 2015
Steven Parker
@Philosophist
Aug 02 2015 00:00
Got it! Thanks @moigithub!
Kolloom
@Kolloom
Aug 02 2015 00:01
@weirdhockeygirl16 any error message?
Alanna M
@weirdhockeygirl16
Aug 02 2015 00:01
Did you define a perimeterBox function? is what it says @Kolloom
Kolloom
@Kolloom
Aug 02 2015 00:02
function is misspelled
David Taylor
@cornjacket
Aug 02 2015 00:02
Hello everyone
Kolloom
@Kolloom
Aug 02 2015 00:03
hey @cornjacket
Alanna M
@weirdhockeygirl16
Aug 02 2015 00:03
@Kolloom stupid me, Perimeter is spelled wrong
Kolloom
@Kolloom
Aug 02 2015 00:04
@weirdhockeygirl16 got cha :)
cblupodev
@cblupodev
Aug 02 2015 00:05
This message was deleted
ericblobb
@ericblobb
Aug 02 2015 00:05
In the Waypoint: GIv a background color to a div element, I did all the things it asked me but it isn't letting me proceed to the next Waypoint
Is something up?
Oh nevermind
I just spelled "grey" differently
cblupodev
@cblupodev
Aug 02 2015 00:06
This message was deleted

accidentily deleted that
I'm working on Express waypoint
asdf

var express = require("express"),
    fs = require("fs");
var app = express();    

app.get('/',function(req, res){
    app.use(express.static(process.argv[3] + '/index.html'.join(__dirname, 'public')));  // I'm getting error "TypeError: undefined is not a function" at .join
}).listen(process.argv[2]);

Why am I getting the error at the 'app.use' line?

Timothy Touch
@timtouch
Aug 02 2015 00:10
I don't think you put app.use in the app.get
cblupodev
@cblupodev
Aug 02 2015 00:10
@timtouch So where do I put the middlware snippit? In the .listen callback?
David Taylor
@cornjacket
Aug 02 2015 00:10
hi @Kolloom
Timothy Touch
@timtouch
Aug 02 2015 00:12
@cblupodev Just by itself, no app.get
cblupodev
@cblupodev
Aug 02 2015 00:15
@timtouch This is all my code expect the requires. Still the same error
app.listen(process.argv[2]);
app.use(express.static(process.argv[3] + '/index.html'.join(__dirname, 'public')));
SojournerOctocat
@SojournerOctocat
Aug 02 2015 00:15
Working on Bonfire Search and Replace. This is what I have so far. What's being returned in the original str. What am I doing wrong that it's actually replacing the substring?
function replace(str, before, after) {
    function replaceConsideringCase(match) {
        return after;
    }

    return str.replace(/before/i, replaceConsideringCase);
}

replace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Moisés Man
@moigithub
Aug 02 2015 00:16
@cblupodev copy the "hint" code ??
app.use(express.static(process.argv[3] + '/index.html'.join(__dirname, 'public'))); <-- ur code
app.use(express.static(process.argv[3] + '/index.html' || path.join(__dirname, 'public'))); <-- hint code
@cblupodev
Dan Morency
@g0shdanit
Aug 02 2015 00:19
Oops, try again. Make sure to put some text between your <p></p> tags!
$(document).ready(function() {
$('#one').after('<p>paragraph</p>');
});
cblupodev
@cblupodev
Aug 02 2015 00:19
@moigithub @timtouch That works. But it doesn't make sense to me. What the heck is path?
Dan Morency
@g0shdanit
Aug 02 2015 00:19
Whats up with that?
Matt Yamamoto
@MattYamamoto
Aug 02 2015 00:19
@SojournerOctocat your replaceConsideringCase function is never called, although I'm not clear what it does. In any event, your simply returning the string after running the replace method. But you're searching for the word "before" to replace...since the string does not containe "before" in it nothing is replaced, hence the original string is returned.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 00:20
@MattYamamoto How do I get it to search for the variable before instead of the word before?
Moisés Man
@moigithub
Aug 02 2015 00:20
@cblupodev https://nodejs.org/api/path.html <-- this is path a node module
cblupodev
@cblupodev
Aug 02 2015 00:21
@moigithub Thanks!
Matt Yamamoto
@MattYamamoto
Aug 02 2015 00:22
@SojournerOctocat you don't need to use a regular expression, you can simply use the variable before there. str.replace(before, replaceConsideringCase)
SojournerOctocat
@SojournerOctocat
Aug 02 2015 00:23
@MattYamamoto I need to use a regular expression in order to tell it to ignore case.
Maybe that will help
SojournerOctocat
@SojournerOctocat
Aug 02 2015 00:28
@timtouch That's what I have in my code!
Matt Yamamoto
@MattYamamoto
Aug 02 2015 00:30
@SojournerOctocat I think he means create a variable to hold the regex: var re = new RegExp(before, "ig");
Timothy Touch
@timtouch
Aug 02 2015 00:31
@MattYamamoto @SojournerOctocat Yeah, that's what I was trying to hint at
SojournerOctocat
@SojournerOctocat
Aug 02 2015 00:31
@MattYamamoto @timtouch Ah, that worked. Thanks!
Ingrid
@voodoobettie
Aug 02 2015 00:44
What does "expected false to deeply equal true" mean?
Matt Yamamoto
@MattYamamoto
Aug 02 2015 00:45
yours returned false when it should have been true.
Joe
@reitmanj
Aug 02 2015 00:51
Anyone finished with Symmetric Difference? I'm confused with one of expected test results.
Matt Yamamoto
@MattYamamoto
Aug 02 2015 00:52
@reitmanj which one?
Joe
@reitmanj
Aug 02 2015 00:54
@MattYamamoto
assert.deepEqual(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]), [1, 4, 5], 'should return an array of unique values');should return an array of unique values: expected [ 1, 1, 4, 5, 5 ] to deeply equal [ 1, 4, 5 ]
@MattYamamoto I thought the 2 would also be part of the answer.
Matt Yamamoto
@MattYamamoto
Aug 02 2015 00:57
oh yeah, I remember this one making my head hurt. Hang on, I have to think about it
Timothy Touch
@timtouch
Aug 02 2015 00:57
Haha
Matt Yamamoto
@MattYamamoto
Aug 02 2015 00:59
I remember I had to watch the youtube video on symmetric difference like 3 times
Timothy Touch
@timtouch
Aug 02 2015 01:00
So the symdiff of [1,1,2,5] and [2,2,3,5] is [1,3] and then you take the symdiff of [1,3] and [3,4,4,5] and you get [1,4,5]
Matt Yamamoto
@MattYamamoto
Aug 02 2015 01:01
yes! haha...I kept getting that but I misread the test...I thought it was te symdiff of four arrays where the fourth was [1,4,5]... so I was thinking the answer was nothing! doh!
I just drew out this crazy picture with 4 interseting circles to try to make sure I was thinking correctly. ahaha!
Joe
@reitmanj
Aug 02 2015 01:02
I'm still hung up on the 2.
[1,1,2,5] and [2,2,3,5] has a pair of 2's and one extra
Matt Yamamoto
@MattYamamoto
Aug 02 2015 01:04
The symmetric difference of three groups of numbers will include numbers unique to a group (array) AND numbers that are in all three.
dshen88
@dshen88
Aug 02 2015 01:04
Hey guys can anyone explain to me really quick what a "line break" does?
ex: <br>
Joe
@reitmanj
Aug 02 2015 01:04
Ahhhh. Ok
hakimnasir
@hakimnasir
Aug 02 2015 01:04
This message was deleted
Steven Parker
@Philosophist
Aug 02 2015 01:06
On Pairwise bonfire challenge, why does the output expect 11 for the return value and not 14? I'm also confused by what it means by multiple possible sums. http://www.freecodecamp.com/challenges/bonfire-pairwise
Matt Yamamoto
@MattYamamoto
Aug 02 2015 01:08
@Philosophist it wants the sum of the indicies, not the values themselves
Steven Parker
@Philosophist
Aug 02 2015 01:09
@MattYamamoto Ohhh, that makes more sense!
Thanks!
Matt Yamamoto
@MattYamamoto
Aug 02 2015 01:10
sure thing.
Shouvik Roy
@royshouvik
Aug 02 2015 01:10
Would anyone like to discuss implementing reduce using recursion, am having a tough time
Steven Parker
@Philosophist
Aug 02 2015 01:12
I'm trying out reduce for the first time. Why am I getting 5 for the first test case?
function pairwise(arr, arg) {
  var sum = arr.reduce(function(previousValue, currentValue, index, array){
    if (array.indexOf(arg-currentValue) !== -1){
      return previousValue + index;
    }else{
      return 0;
    }

  });
  return sum;
}

pairwise([1,4,2,3,0,5], 7);
Shouvik Roy
@royshouvik
Aug 02 2015 01:18
@Philosophist why this check ? array.indexOf(arg-currentValue) !== -1)
Timothy Touch
@timtouch
Aug 02 2015 01:19
else{return 0;} resets previousValue to 0
Steven Parker
@Philosophist
Aug 02 2015 01:20
@royshouvik I'm supposed to add the index value if the required pair value to sum to arg exists. indexOf gives -1 for values that do not exist... dammit, I think I just figured it out
@timtouch Yup, that's it! Thanks everyone!
Matt Yamamoto
@MattYamamoto
Aug 02 2015 01:21
@Philosophist I think you need an initial value too, no?
Steven Parker
@Philosophist
Aug 02 2015 01:23
function pairwise(arr, arg) {
  var sum = arr.reduce(function(previousValue, currentValue, index, array){
    if (array.indexOf(arg-currentValue) !== -1){
      return previousValue + index;
    }else{
      return previousValue;
    }
  }, 0);
  return sum;
}

pairwise([1, 3, 2, 4], 4);
@MattYamamoto Yup, that fixes test case 1. Now test case 2 here gives me a 3
Wait, I see it!
function pairwise(arr, arg) {
  var sum = arr.reduce(function(previousValue, currentValue, index, array){
    if (array.indexOf(arg-currentValue) !== -1 && arg-currentValue !== currentValue){
      return previousValue + index;
    }else{
      return previousValue;
    }
  }, 0);
  return sum;
}

pairwise([1, 3, 2, 4], 4);
Almost there...
Mark Dang
@dangm24
Aug 02 2015 01:29
Hey all, I could use quick help on the Bonfire: Pig Latin
Timothy Touch
@timtouch
Aug 02 2015 01:32
You've come to the right chatroom
cblupodev
@cblupodev
Aug 02 2015 01:32

Working on the Express waypoint
asdf
asdf

var express = require("express");
var app = express();

app.listen(process.argv[2]);
app.use(require('stylus').middleware(__dirname + '/public'));
app.use(express.static(process.argv[3] + '/main.css'||path.join(__dirname, 'public'))); // problem line
app.use(express.static(process.argv[3] + '/index.html'||path.join(__dirname, 'public')));

Why the error?

Alanna M
@weirdhockeygirl16
Aug 02 2015 01:37
What symbol do i use if i want to have a range of numbers in java? etc. if i want 0-33 how would do that
cblupodev
@cblupodev
Aug 02 2015 01:37
@weirdhockeygirl16 javascript?
Alanna M
@weirdhockeygirl16
Aug 02 2015 01:38
@cblupodev yup
cblupodev
@cblupodev
Aug 02 2015 01:40
var ar = new Array(34);
ar.map(function(element, idx) { return idx; });
Like this?
Alanna M
@weirdhockeygirl16
Aug 02 2015 01:40
no like in a if statement
if()
cblupodev
@cblupodev
Aug 02 2015 01:41
@weirdhockeygirl16
if (0 <= somethingVariable && somethingVariable <= 33) ?
Alanna M
@weirdhockeygirl16
Aug 02 2015 01:41
ill try it
Shouvik Roy
@royshouvik
Aug 02 2015 01:43
anyone tried the functional javascript exercise on NodeSchool? its damn hard and awesome at the same time
Steven Parker
@Philosophist
Aug 02 2015 01:43
Challenge completed! Thanks helper peeps! What do you think of this final product? Did I over-complicate it a little?
function pairwise(arr, arg) {
  var sum = arr.reduce(function(previousValue, currentValue, index, array){
    if (array.indexOf(arg-currentValue) !== -1 && array.indexOf(arg-currentValue) !== index){
      var add = index + array.indexOf(arg-currentValue);
      arr[index] = 'x';
      arr[array.indexOf(arg-currentValue)] = 'x';
      return previousValue + add;
    }else{
      return previousValue;
    }
  }, 0);
  return sum;
}

pairwise([1, 3, 2, 4], 4);
Luis Felipe López G.
@luishendrix92
Aug 02 2015 01:45
Hey, I am in the Learn Javascript waypoints, I used a recursion just for fun but I'm not sure if I'm using them correctly, I don't want to misuse regexps and recursions so I wish to know if this could be done in a simpler and cleaner way:
var userChoice = validatePrompt();

function validatePrompt(answer) {
    if ( /^(rock|paper|scissors?)$/i.test(answer) ) {
        return answer;
    } else {
        return validatePrompt( prompt("Do you choose rock, paper or scissors?") );
    }
}
Matt Yamamoto
@MattYamamoto
Aug 02 2015 01:46
@Philosophist haha...I was going to say that it's probably not the most straight forward way, but I'm glad you got it to work.
Steven Parker
@Philosophist
Aug 02 2015 01:49
@MattYamamoto Thanks! Is there a trick I might have used along the way? maybe something that's better than reduce, or a way to get reduce to skip certain indexes (besides making them fail the if check of course)?
Matt Yamamoto
@MattYamamoto
Aug 02 2015 01:53
@Philosophist Well, I'm not too sure of the most efficient way. I did something similar to you, I just used a for loop instead using reduce. I don't feel my was all that efficient either.
articulating
@articulating
Aug 02 2015 02:01
Without using string.split, can you still change letters? ie, can I do "hello"1='b'
[]*
dc
@dcsan
Aug 02 2015 02:02
@articulating nope. JS strings are immutable
John Chau
@ydjjabt
Aug 02 2015 02:02
hi , i need help centering the "Free Code Camp Zipline" in the top line by itself on any screen(ie responsive) and on the second line right beneath the first line I need "Local Weather App" center by itself in the second line too
http://codepen.io/ydjjabt/pen/vOQxNp?editors=101
articulating
@articulating
Aug 02 2015 02:02
@dcsan ok thought so, thanks.
John Chau
@ydjjabt
Aug 02 2015 02:02
@dcsan depend on the string method, string replace method is mutable
dc
@dcsan
Aug 02 2015 02:02
doesn tthat just create a new string?
try extending the String class and modify this - no dice
s="red"
"red"
s[1]
"e"
s[1]="x"
"x"
s
"red"
Steven Parker
@Philosophist
Aug 02 2015 02:08
@MattYamamoto lol, ok, then I guess I can just count myself as having done a competitively good job!
articulating
@articulating
Aug 02 2015 02:11
function titleCase(str) {
  var ar = str.split(' ');
  for (var sentence in ar) {
    ar[sentence] = ar[sentence].toLowerCase();
    var sp=ar[sentence].split('');
    sp[0] = sp[0].toUpperCase();
    ar[sentence] = sp.join('');
  }
  return ar.join(' ');
}

titleCase("I'm a little tea pot");
This works, but is there a better way to do it?(change the first letter of every word to capital and the others to lowercase)
John Chau
@ydjjabt
Aug 02 2015 02:14
come on guys and girls, help me
http://codepen.io/ydjjabt/pen/vOQxNp?editors=100
i need the "Free Code Camp Zipline" and the "Local Weather App' both in the center
TJ Martin
@tmartin2089
Aug 02 2015 02:16
question about .apply()
is it basically just a way to apply some non-array methods to an array input?
sort of the opposite of Array.prototype.splice.call(arguments)
Luis Felipe López G.
@luishendrix92
Aug 02 2015 02:27
@tmartin2089 Check this video, it helps: https://www.youtube.com/watch?v=HYA6vO0sej8
TatyCat
@TatyCat
Aug 02 2015 02:41
Screen Shot 2015-08-01 at 10.40.01 PM.png
Did anyone else have difficulty with the CSS class section?
I can't seem to understand what it's asking of me. I was able to change the text to red...i just can't figure out how to add "red-text"
John Chau
@ydjjabt
Aug 02 2015 02:42
how do u space the top two lines from the rest
http://codepen.io/ydjjabt/pen/vOQxNp?editors=110
Luis Felipe López G.
@luishendrix92
Aug 02 2015 02:45
@ydjjabt Try adding to your CSS margin-bottom: 20px; in #top{ }
John Chau
@ydjjabt
Aug 02 2015 02:49
@luishendrix92 not working
TatyCat
@TatyCat
Aug 02 2015 02:54
I mean...obviously I can just change blue to say red...or I can follow the example and put <style> h2 {color: red;}</style> but that isn't satisfying the "red-text" requirement to get through this challenge.
AaronOoooo
@AaronOoooo
Aug 02 2015 02:54
I need help on Basic Javascript: Build a Contact List: 6/6
Anyone up for helping me out on this one?
I'm sorry, The section is Build an Address Book.
TatyCat
@TatyCat
Aug 02 2015 02:56
Sorry...I can't help. I'm still in the beginning stages of CSS/HTML and needing assistance with that sigh.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 02:56
var str = "A quick brown fox jumped over the lazy dog";
var i ="Jumped";
var j = "leaped";
var k = str.split(" "); // [ 'A', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy', 'dog' ]
var l = k.indexOf(i.toLowerCase()); // 4
var m = j.charAt(0).toUpperCase() + j.slice(1); // Leaped

console.log(k.splice(4, 1, m)); // [ 'jumped' ]
Why is console only printing [jumped]? I'm expecting the slice to removed jumped from the array and replace it with Leaped.
AaronOoooo
@AaronOoooo
Aug 02 2015 02:56
@TatyCat That's OK. I know you would help if you could :)
TatyCat
@TatyCat
Aug 02 2015 02:56
:)
SojournerOctocat
@SojournerOctocat
Aug 02 2015 02:57
@AaronOoooo What is the link for the waypoint?
Let me know if you want me to paste my code.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 02:59
@AaronOoooo Yes, please paste your code.
AaronOoooo
@AaronOoooo
Aug 02 2015 03:00
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
}

function list() {
    var contactsLength = contacts.length;
    for (var i = 0; i < contactsLength; i++) {
        printPerson(contacts[i]);
    }
}

/*Create a search function
then call it passing "Jones"*/
function search (lastName) {
    var contactsLength = contacts.length;
    for (var i = 0 ; i < contactsLength; i++){
        if (contacts[i].lastName === lastName) {
            printPerson(contacts[i]);
        }
    }
}


function add(firstName, lastName, email, phoneNumber) {
    contacts[contacts.length] {
        firstName: firstName,
        lastName: lastName,
        phoneNumber: phoneNumber,
        email: email
    }
}

add("Aaron", "O", "773-777-9999", "tucky@gmail.com");
search("Pill");
SojournerOctocat
@SojournerOctocat
Aug 02 2015 03:08
@AaronOoooo In the function add section, you need to add an equal sign: contacts[contacts.length] = {
AaronOoooo
@AaronOoooo
Aug 02 2015 03:09
@SojournerOctocat WOW! Thank you!! That did the trick!
I will never forget that equals sign again! Whew!
SojournerOctocat
@SojournerOctocat
Aug 02 2015 03:10
:)
I'm usually missing semi-colons. Those little things can escape our notice sometimes. Especiallly with longer blocks of code.
AaronOoooo
@AaronOoooo
Aug 02 2015 03:13
The Build an Address Book section is LOOOONG! And I am a bit tired of it. So at this point, it was difficult for me to see that omission.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 03:15
Yeah. And the error given wasn't helpful. It would have you looking for brackets being off somewhere.
AaronOoooo
@AaronOoooo
Aug 02 2015 03:16
Exactly!
qoiuy
@Qoiuy
Aug 02 2015 03:26
hello everyboy,myname is qoiuy ,I'mfrom china .
Brian
@bwobst
Aug 02 2015 03:28
Anyone know how this code works?
return R.difference([1, 2, 3], [1, 3]);
Rodrigo Fierro R.
@rodrigofierro
Aug 02 2015 03:31
@Qoiuy Welcome
qoiuy
@Qoiuy
Aug 02 2015 03:34
@rodrigofierro Thanks .heihei .
Sergey Zhidkov
@sergey-zhidkov
Aug 02 2015 03:41
@bwobst Where is this code from?
SojournerOctocat
@SojournerOctocat
Aug 02 2015 03:42
Working on Bonfire Search and Replace. The code below should replace jumped with Leaped, but it's replacing it with a lowercase leaped. Any suggestions?
function replace(str, before, after) {
    var re = new RegExp(before, "i");

    function replaceConsideringCase(match) {
        if(before.charAt(0) === before.charAt(0).toUpperCase){
            var beforeLength = before.length;
            var arrSplitString = str.split(" ");
            var beforeIndexInString = arrSplitString.indexOf(before.toLowerCase());
            var afterUpperCase = after.charAt(0).toUpperCase() + after.slice(1);

            arrSplitString.splice(beforeIndexInString, 1, afterUpperCase);

            return arrSplitString.join(" ");
        } else {
            return after;
        }
    }

    return str.replace(re, replaceConsideringCase);
}

replace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
Rex Schrader
@SaintPeter
Aug 02 2015 03:43
@SojournerOctocat Have you added some console.log statements to see if afterUpperCase is correct?
SojournerOctocat
@SojournerOctocat
Aug 02 2015 03:44
@SaintPeter I tested it in a separate block of code.
Before adding it to this code.
DTing
@dting
Aug 02 2015 03:46
@SojournerOctocat the conditional with the before.charAt(0) === ... needs to be changed. That's an invariant to the input before. You are looking to see if the matched word is upper or lower case. Also if the code ever took that path i think you would replace your match with the entire string
Brian
@bwobst
Aug 02 2015 03:46
@sergey-zhidkov @terakilobyte 's profile
Rex Schrader
@SaintPeter
Aug 02 2015 03:47

@SojournerOctocat Here is the problem:

if(before.charAt(0) === before.charAt(0).toUpperCase){

You're missing the parentheses after toUpperCase()

@SaintPeter Or, at least, that's part of the problem. There may be other issues.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 03:50
@dting @SaintPeter The missing parentheses were part of the problem. And now the code is replacing the match with the entire string. I don't understand how to change the before.charAt(0) === … to change that though.

function replace(str, before, after) {
    var re = new RegExp(before, "i");

    function replaceConsideringCase(match) {
        if(before.charAt(0) === before.charAt(0).toUpperCase()){
            var arrSplitString = str.split(" ");
            var beforeIndexInString = arrSplitString.indexOf(before.toLowerCase());
            var afterUpperCase = after.charAt(0).toUpperCase() + after.slice(1);

            arrSplitString.splice(beforeIndexInString, 1, afterUpperCase);

            return arrSplitString.join(" ");
        } else {
            return after;
        }
    }

    return str.replace(re, replaceConsideringCase);
}

replace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
@dting What do you mean by "That' s an invariant to the input before."
Sergey Zhidkov
@sergey-zhidkov
Aug 02 2015 03:51
var beforeIndexInString = arrSplitString.indexOf(before.toLowerCase()); @SojournerOctocat this is your problem
DTing
@dting
Aug 02 2015 03:51
@SojournerOctocat you aren't checking if the matching part of the string is capitalized.
@SojournerOctocat you are checking that the variable before is capitalized or not.
Sergey Zhidkov
@sergey-zhidkov
Aug 02 2015 03:52
This message was deleted
SojournerOctocat
@SojournerOctocat
Aug 02 2015 03:55
@dting I'm checking if the variable is capitalized because someone in another chat room told me that it was the before variable that is capitalized, not the text in the search string.
DTing
@dting
Aug 02 2015 03:56
Hmm interesting. Lemme look.
@SojournerOctocat NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word 'Book' with the word 'dog', it should be replaced as 'Dog'
hmm that is kind of ambigous still. haha
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:00
I'm taking their word for it as they said they had completed the bonfire.
DTing
@dting
Aug 02 2015 04:00
That makes me think that the regex match shouldn't be case insensitive. The test cases they use actually don't make it clear one way or the other tho. Every test case the word being matched, matches the case of the "before" variable. And there are no matches that are off by capitalization.
The test cases are loose enough that either way will solve the problem.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:01
@dting If capitalization isn't an issue at all, why are they saying it is?
Also, why is the string repeating itself in the string?
DTing
@dting
Aug 02 2015 04:03
because you return
    arrSplitString.splice(beforeIndexInString, 1, afterUpperCase);
    return arrSplitString.join(" ");
the function returns what the match should be replaced with
you return the entire string
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:04
function replace(str, before, after) {
    var afterUpperCase = after.charAt(0).toUpperCase() + after.slice(1);
    return afterUpperCase;
}

replace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
That returns 'Leaped'. However, I put that same var line into my code and all of sudden, it wants to add a bunch of other stuff to the after variable. What on earth is going on?
Rex Schrader
@SaintPeter
Aug 02 2015 04:05
@SojournerOctocat You also need to cover the alternate case: going to lower case
DTing
@dting
Aug 02 2015 04:05
    function replaceConsideringCase(match) {
        if(before.charAt(0) === before.charAt(0).toUpperCase()){
            return after.charAt(0).toUpperCase() + after.substring(1);
        } else {
            return after.charAt(0).toLowerCase() + after.substring(1);
        }
    }
articulating
@articulating
Aug 02 2015 04:06
Can anyone point me in the right direction for chunky monkey? (write a function to seperate an array into size n chunks)
DTing
@dting
Aug 02 2015 04:07
but really to simplify everything don't do this for every match. Just check the case before doing the replace and do str.replace(before, "case corrected after");
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:08
@dting Why does it work on one side and change into something completely different in a different block of code. after is a word. If I'm changing the first character to uppercase, and adding the rest of the word, why is it instead giving me the replacement string?
DTing
@dting
Aug 02 2015 04:08
the replaceConsideringCase function is being used as a callback for your str.replace
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:09
@articulating Hint: You can iterate in size n chunks.
DTing
@dting
Aug 02 2015 04:09
whenever str.replace finds a match using your re expression. It calls the replaceConsideringCase function with the match as the argument to see what it should replace the match with.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:10
@dting Are you saying that afterUpperCase is calling replaceConsideringCase?
articulating
@articulating
Aug 02 2015 04:10
@SojournerOctocat example? as in i+=2 or 3 as opposed to just i++ in the for loop?
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:11
@articulating Well, you wouldn't want to hard-code a number because you have to pass the other tests as well...
@articulating You might want to use a variable ...
articulating
@articulating
Aug 02 2015 04:11
@SojournerOctocat well yeah I know I was giving an example
DTing
@dting
Aug 02 2015 04:11
@SojournerOctocat yes
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:12
@dting How do I get it to stop doing that.
Steven Parker
@Philosophist
Aug 02 2015 04:12
Map function.png
DTing
@dting
Aug 02 2015 04:12
You don't need a function there.
function replace(str, before, after) {
  if (before.charAt(0) === before.charAt(0).toUpperCase()) {
    after = after.charAt(0).toUpperCase() + after.substring(1);
  } else {
    after = after.charAt(0).toLowerCase() + after.substring(1);
  }
  return str.replace(before, after);
}
Steven Parker
@Philosophist
Aug 02 2015 04:13
Pretty sure that after hitting show answer it's supposed to work, but it doesn't... bug report?
DTing
@dting
Aug 02 2015 04:13
you pass that function to the str.replace thats why its calling it.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:14
Your code isn't working either. Nothing gets changed, @dting
@dting Your code doesn't work when something is capitalized…
function replace(str, before, after) {
  if (before.charAt(0) === before.charAt(0).toUpperCase()) {
    after = after.charAt(0).toUpperCase() + after.substring(1);
  } else {
    after = after.charAt(0).toLowerCase() + after.substring(1);
  }
  return str.replace(before, after);
}

replace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
DTing
@dting
Aug 02 2015 04:16
That isn't one of the test cases.
but ya. It's because Jumped isnt matched
Jumped doesnt appear in "A quick brown fox jumped over the lazy dog"
If it was in the string. It works like expected.
function replace(str, before, after) {
  if (before.charAt(0) === before.charAt(0).toUpperCase()) {
    after = after.charAt(0).toUpperCase() + after.substring(1);
  } else {
    after = after.charAt(0).toLowerCase() + after.substring(1);
  }
  return str.replace(before, after);
}

replace("A quick brown fox Jumped over the lazy dog", "Jumped", "leaped");
"A quick brown fox Leaped over the lazy dog"
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:18
@dting Why do you use substring instead of slice?
justindobbs
@justindobbs
Aug 02 2015 04:19
Is there any special trick to the Exact Change bonfire?
@justindobbs watch out for floating point inaccuracy.
Nic Galluzzo
@ngalluzzo
Aug 02 2015 04:20
@justindobbs just do it!!!
i’m currently on that one hah
justindobbs
@justindobbs
Aug 02 2015 04:21
I thought I finished it but it says that array(7) is not array(7)
DTing
@dting
Aug 02 2015 04:22
@SojournerOctocat no particular reason.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:24
@dting Just curious. I thought it might be doing something different under the hood. All that code I wrote, pointless. Useless. Unnecessary. I don't know if I should be relieved or not.
I didn't even think of doing it that way.
DTing
@dting
Aug 02 2015 04:24
@SojournerOctocat Never pointless. Learning experiences. =)
@justindobbs I'm guessing your off by a penny if you are using floats.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:27
@dting Thanks for the help and the explanations!
justindobbs
@justindobbs
Aug 02 2015 04:27
no i solved the floats problem
mainly using precisionTo() for the decibels
articulating
@articulating
Aug 02 2015 04:28
dumb question: say my for loop is for(var i =0;i<5;i++); will the loop run with i === 0 or not
DTing
@dting
Aug 02 2015 04:28
@SojournerOctocat nps
Nic Galluzzo
@ngalluzzo
Aug 02 2015 04:29
no @articulating
i=0 is a variable assignment, i===0 is a comparison
DTing
@dting
Aug 02 2015 04:29
@articulating yes. it starts at 0 ends at 4
Luis Felipe López G.
@luishendrix92
Aug 02 2015 04:29
@articulating It will, but your last expression (i++) should decrease "i" instead (i--) and the var i = 0 should be longer than 0
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:29
@articulating Are you still doing Chunky Monkey?
Nic Galluzzo
@ngalluzzo
Aug 02 2015 04:29
ohh nvm i misunderstood
articulating
@articulating
Aug 02 2015 04:29
@SojournerOctocat yes
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:30
@articulating What's your code look like?
articulating
@articulating
Aug 02 2015 04:31
@SojournerOctocat I think ive almost got it
Luis Felipe López G.
@luishendrix92
Aug 02 2015 04:32
@articulating Nevermind, just consoled it and doesn't work :S dunno what I did wrong
DTing
@dting
Aug 02 2015 04:33
@justindobbs can i see your code?
justindobbs
@justindobbs
Aug 02 2015 04:34
yah, should i just paste it here?
DTing
@dting
Aug 02 2015 04:34
sure
articulating
@articulating
Aug 02 2015 04:35
This message was deleted
nvm
dc
@dcsan
Aug 02 2015 04:36
probably you ahve an extra }
javascript :anger:
if only es6 was more like coffeescript
justindobbs
@justindobbs
Aug 02 2015 04:41
//toPrecision and *100/100 are used to handle decimal problems in js
    var remainder = cash.toPrecision(6)-price.toPrecision(6);

    var currencies = 
     [['PENNY', 0.00],
        ['NICKEL', 0.00],
        ['DIME', 0.00],
        ['QUARTER', 0.00],
        ['ONE', 0.00],
        ['FIVE', 0.00],
        ['TEN', 0.00],
        ['TWENTY', 0.00],
        ['ONE HUNDRED', 0.00]];

    var legend = [0.01,0.05,0.10,0.25,1.0,5.0,10.0,20.0,100.0];

    //create new array that merges together duplicate arrays(based on currency type) while adding the matched currency number to the array merged to 
    var r = cid.reduce( function(prev,curr){
        var truthey = true;
        var id;
        if(prev){
            //loop over the newly created accumulated array
            //compare the currency string[such as 'penny'] against the currency string of the current item[curr]
            for(var i=0;i<prev.length;i++){
                if( prev[i][0] === curr[0] ){
                    truthey = false;
                    id=i;
                }
            }
            if( truthey ){
                prev.push(curr);
            }
            else{
                prev[id][1] = prev[id][1]+parseInt(curr[1].toPrecision(6));
            }
        }
        return prev;
    },[]);

  console.log(r); 

    //need to add up our drawer so that we can see if there is sufficient change, also for equal change, which would flag 'Closed'
    var reduction = cid.reduce( function( prev,curr){
        return prev+parseInt(curr[1].toPrecision(6));
    },cid[0][1]);

  return reduction;

  if( (reduction*100)/100 === (remainder*100/100) ){
        return 'Closed';
  }

    else if( reduction<remainder ){
        return 'Insufficient Funds';
    }

    //tick lowers to lower currency when remainder is higher than the currency legend
    else{
        var tick = cid.length-1;
        while( tick>=0 ){
            if( remainder>=legend[tick] ){
                remainder-=legend[tick].toPrecision(6);
                currencies[tick][1] = currencies[tick][1]+legend[tick];
                cid[tick][1] = cid[tick][1]+legend[tick];
            }
            else{
                tick--;
            }
        }
        return currencies.filter( function( currency ){
            return currency[1]>0.00;
        });
    }
articulating
@articulating
Aug 02 2015 04:43
function chunk(arr, size) {
  // Break it up.
  var newar = [];
  for (var i = 0; i<arr.size; i+=size){
    var ar2 = [];
    for (var j = 0; j<size;j++) {
      if (arr[i+j] === null) {
        newar.push(ar2);
        return newar;
      }
      ar2.push(arr[i+j]);
    }
    newar.push(ar2);
  }
  return newar;
}

chunk(['a', 'b', 'c', 'd'], 2);
Am I doing it all wrong? my brain is not working
Sophanarith Sok
@sok213
Aug 02 2015 04:45
In Bonfire: Symmetric Difference, for the second test, why does it expect the result to equal [1,4,5] if 5 is in all of the arrays?
Nic Galluzzo
@ngalluzzo
Aug 02 2015 04:46
@suk
[1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5]

first array = [1,3], then compare to [3,4,5]
second array = [1, 4, 5]
articulating
@articulating
Aug 02 2015 04:47
fixed
why did i write .size -_-
Nic Galluzzo
@ngalluzzo
Aug 02 2015 04:47
sorry @sok213
DTing
@dting
Aug 02 2015 04:48
@justindobbs ya you still have a floating point inaccuracy error
Sophanarith Sok
@sok213
Aug 02 2015 04:48
@ngalluzzo I see, Thanks.
articulating
@articulating
Aug 02 2015 04:50
should return the last chunk as remaining elements: expected [ Array(2) ] to deeply equal [ [ 0, 1, 2, 3 ], [ 4, 5 ] ]
how do I do this? code above
justindobbs
@justindobbs
Aug 02 2015 04:52
@dting thanks i'll take another look
DTing
@dting
Aug 02 2015 04:53
[["PENNY",0.03],["DIME",0.2],["QUARTER",0.5],["ONE",1],["FIVE",5],["TEN",10],["TWENTY",80]] instead of the expected ["PENNY", 0.04]
someone explain me the largest number of a 2D array pls
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:55
@articulating You only need one for loop.
articulating
@articulating
Aug 02 2015 04:55
@SojournerOctocat array.slice?
SojournerOctocat
@SojournerOctocat
Aug 02 2015 04:56
Push the slices @articulating
articulating
@articulating
Aug 02 2015 04:58
@SojournerOctocat thank you finally did it
SojournerOctocat
@SojournerOctocat
Aug 02 2015 05:00
@articulating Congrats!
articulating
@articulating
Aug 02 2015 05:01
up to mutation now
how can i make variable regexs?
SojournerOctocat
@SojournerOctocat
Aug 02 2015 05:03
@articulating Good question. I don't know. I did mine a little differently.
articulating
@articulating
Aug 02 2015 05:05
substring?
SojournerOctocat
@SojournerOctocat
Aug 02 2015 05:06
I used a for loop, then searched using indexOf
rrios1877
@rrios1877
Aug 02 2015 05:11
hi everyone, Im working on waypoint Manage Packages with NPM and I'm stuck on number 6 which asks to create a test.js file and make changes to script in the json.package file. I keep getting the same error; Cannot find module '/home/ubuntu/workspace/test.js'
I was hoping someone might be able to help me with this issue. Thanks in advance!
can someone explain me how to get the largest number in the 2D arrays
John Chau
@ydjjabt
Aug 02 2015 05:21
http://codepen.io/ydjjabt/pen/vOQxNp?editors=110
how do i add a background image of a beach? instead of the baby blue background? i have a beach image here on my laptop.
Luis Felipe López G.
@luishendrix92
Aug 02 2015 05:26

@ydjjabt Uptdate the body { } part in your CSS, replace background-color: #b0c4de; with:

body {
    background: #b0c4de url(http://lorempixel.com/800/600/cats/);
  background-size: cover;
}

You can change what it's between url(--) with your own cat image.
background-size: cover; allows you to expand the background image to cover the whole parent's height and width, in this case, the document's body.

Franco Zapata
@Francozt01
Aug 02 2015 05:28
RONDA! :O
34 Seconds of Fight!
DTing
@dting
Aug 02 2015 05:29
That was longer than i thought it was going to be.
Franco Zapata
@Francozt01
Aug 02 2015 05:29
was KO by punches
John Chau
@ydjjabt
Aug 02 2015 05:36
@luishendrix92 nice man!, i like a lot better than before
John Chau
@ydjjabt
Aug 02 2015 05:49
how come $.getJSON('https://api.twitch.tv/kraken', function(result){
console.log(result)
}) doesnt return a nice JSON object
Bin Ury
@teddy-error
Aug 02 2015 05:59
What does your console debugger say?
XMLHttpRequest cannot load https://api.twitch.tv/kraken. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://gitter.im' is therefore not allowed access
@ydjjabt
John Chau
@ydjjabt
Aug 02 2015 06:05
@teddy-error XMLHttpRequest cannot load https://api.twitch.tv/kraken. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
pen.js:4 Uncaught ReferenceError: user is not defined
For this, is there any better way than filter(function(el) el !== null && el !== false && el !== 0
etc
Tristanto
@rustyworks
Aug 02 2015 06:12
All, in Bonfire: Make a Person, should I put the "split" logic inside constructor ?
Bin Ury
@teddy-error
Aug 02 2015 06:31
@ydjjabt twitch's api is blocking you
so you need to need to flag your request as a "JSONP" type
Bin Ury
@teddy-error
Aug 02 2015 06:38
$.ajax({
    url: "https://api.twitch.tv/kraken",
    // Tell jQuery we're expecting JSONP
    dataType: "jsonp",

    // Work with the response
    success: function( response ) {
        console.log(response ); // server response
    }
});
annchichi
@annchichi
Aug 02 2015 06:45

Hi @all, does anyone know why I need to have the else { return false;} outside for loop rather than what I wrote here? Shouldn’t the if stops, when it checked sth is correct already? function PowersofTwo(num) {

for (var i = 0; i<num; i++) {

var result = Math.pow(2,i);

if (result === num) {
    return true;
} else {
    return false;
}

}

}

console.log(PowersofTwo(49));

Thanks~
Robert
@rc242
Aug 02 2015 06:50
@annchichi: Since you have a returns in your if statement, you'll need to satisfy one or more return values for the remaining "exit" paths. Or, you could just have one for all remaining paths with a return as your last statement in the function.
Stoyan Ekupov
@StIvEk
Aug 02 2015 06:55

@annchichi You can shorten you return statement to

return result === num;

it will return true or false following the same logic

John Chau
@ydjjabt
Aug 02 2015 06:58
@teddy-error dude, ur a damn beast!
mad prop man mad prop!
Ingrid
@voodoobettie
Aug 02 2015 06:59
Can anyone help me with figuring out how to get the spaces to match on the palindrome bonfire? I can't get the tests with spaces to match because they end up in the wrong spot when I reconstruct the string after reversing it. e.g. I get "neve ro ddo reven" instead of "never odd or even", and so the test fails.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:01
@voodoobettie Well, most people don't get the spaces to match; instead, they simply remove all the spaces.
Bin Ury
@teddy-error
Aug 02 2015 07:02
@ydjjabt :) no probs
John Chau
@ydjjabt
Aug 02 2015 07:03

@teddy-error

$.get("https://api.twitch.tv/kraken",function(data,status,xhr){console.log(data);},"jsonp")

my errror is the dataType expected from the server....lol programming...so damn picky

Ingrid
@voodoobettie
Aug 02 2015 07:03
@SojournerOctocat Okay, I guess I need a 4th var to strip the spaces from the backward string too then...
John Chau
@ydjjabt
Aug 02 2015 07:04
@teddy-error http://www.w3schools.com/jquery/ajax_get.asp ....i follow them and it work well for the weather API at openweather.com
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:04
@voodoobettie 4th variable?
What variables have you set up so far?
Ingrid
@voodoobettie
Aug 02 2015 07:04
@SojournerOctocat Perhaps not
John Chau
@ydjjabt
Aug 02 2015 07:05
i thought dataType expected from the server is optional as w3school said so and it make sense since whatever the server output back to me, i have to no choice but to accept it whether it be JSONP or json or xml or whatever..
Ingrid
@voodoobettie
Aug 02 2015 07:05
@SojournerOctocat The original string, the regex, the backwards version of the string
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:07
@voodoobettie You might also have to remove punctuation. I don't remember if any of the tests had punctuation.
Ingrid
@voodoobettie
Aug 02 2015 07:07
@SojournerOctocat Yes = "A man, a plan, a canal. Panama"
I think I may have been looking at this for too long
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:07
@voodoobettie Yes, one of the tests has punctuation. You'll need to remove spaces and punctuation.
Bin Ury
@teddy-error
Aug 02 2015 07:08
@ydjjabt it's for security purposes. If you don't specify it in your json get method, it expects JSON and behaves according to that standard. (The standard prevents Javascript from getting things like, say, cookies from another website you're logged into. e.g. you write an ajax request to update my facebook status on your website) So, Twitch forces you to access its API with JSONP which tells Twitch you are coming from a different website, and also passes it a parameter that identifies your request's origin. That is what I have gathered, at least.
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:08
You sound like you're on the right track. Don't give up yet.
Bin Ury
@teddy-error
Aug 02 2015 07:12

@ydjjabt

script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://www.someWebApiServer.com/some-data?callback=my_callback';

Notice the my_callback function over there? So - when (Twitch) JSONP server receives your request and finds callback parameter - instead of returning plain js array it'll return this:

my_callback({['some string 1', 'some data', 'whatever data']});
John Chau
@ydjjabt
Aug 02 2015 07:18
@teddy-error it make sense too what u just said because according to w3school, it optional and that jquery will guess at the expected output type from the server lol, would require the get method to try several times at guessing what type the server would output to me(ie json jsonp xml etc)...the guessing would be security issue then because it like i m hacking ur email account with several tries at different passsword. English and reading is not my thing and so whatever work the first time lol, i 'just do it'(not a Nike fan)...beside it said "Optional. etc...."
Ingrid
@voodoobettie
Aug 02 2015 07:21
@SojournerOctocat Thanks for the help. I did it! :)
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:22
@voodoobettie Yay!!!!
Tristanto
@rustyworks
Aug 02 2015 07:23
Halp, stuck in Bonfire: Map the Debris, anyone can give me a pointer ?
John Chau
@ydjjabt
Aug 02 2015 07:25
@rustyworks dont trust wiki math equation
just plan out the logitstic and find the right equation
dont waste time on the equation
@rustyworks i assume it the asteroid problem?
Tristanto
@rustyworks
Aug 02 2015 07:26
Yes, that's the asteroid problem
Okay, thank you, I'll try @ydjjabt, I already do the rest two advance scripting, but this asteroid :(
John Chau
@ydjjabt
Aug 02 2015 07:28
@teddy-error by the way, what the difference between json and jsonp??? give me the good stuff so i dont have comb over so many search result
annchichi
@annchichi
Aug 02 2015 07:29
@rc242 @StIvEk Thank you for the quick reply. : ) return often gets me a bit confused. @rc242 isn’t else’s return also a remianing ‘exit’ path? Why still it doesn’t stop when if statement is correct? Could you help me understand it more clearly? Thank you guys!
John Chau
@ydjjabt
Aug 02 2015 07:30
@teddy-error also returning json is way better than array because it make perfect sense and easier to use...json is like object(ie key and value)
@annchichi post ur code
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:31
@rustyworks use the wiki formula for 'Small body orbiting a central body'
annchichi
@annchichi
Aug 02 2015 07:31

@ydjjabt I did. Here is it again. Thank you. function PowersofTwo(num) {

for (var i = 0; i<num; i++) {

var result = Math.pow(2,i);

if (result === num) {
    return true;
} else {
    return false;
}

}

}

John Chau
@ydjjabt
Aug 02 2015 07:31
@teddy-error callback=my_callback from the script.src = 'http://www.someWebApiServer.com/some-data?callback=my_callback';
the my_callback would be the dataType????right?maybe i m wrong
Tristanto
@rustyworks
Aug 02 2015 07:33
@StIvEk I assume I already put the formula, but missing one parameter, GM is var GM, a is earthRadius, right ?
@StIvEk Edited GM is mew
John Chau
@ydjjabt
Aug 02 2015 07:33
@annchichi
<script type="text/javascript">
for (var i = 0; i<6; i++) {
var result = Math.pow(2,i);

if (result === num) {
    console.log( true)
} else {
    console.log( false);
}

</script>
write it out on a paper
look ur logic
for (var i = 0; i<6; i++) {
var result = Math.pow(2,i);

if (result === num) {
    console.log( true)
} else {
    console.log( false);
}
}
@annchichi what the purpose of the function
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:35
@rustyworks GM is the var GM, a = earthRadius + avgAlt (https://en.wikipedia.org/wiki/Semi-major_axis)
Ketan Bhatt
@ketanbhatt
Aug 02 2015 07:36
Hey! since screen hero isnt available for linux, how are linux users pairing up?
John Chau
@ydjjabt
Aug 02 2015 07:37
@ketanbhatt lol
ditch linus and go with apple or window lol
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:37
@ketanbhatt TeamViewer
annchichi
@annchichi
Aug 02 2015 07:37
@ydjjabt it is the challenge: Have the function PowersofTwo(num) take the num parameter being passed which will be an integer and return the string true if it's a power of two. If it's not return the string false. For example if the input is 16 then your program should return the string true but if the input is 22 then the output should be the string false. (I am checking out your reply now : ))
SojournerOctocat
@SojournerOctocat
Aug 02 2015 07:37
@ketanbhatt Some people (not just Linux users) use sites like kobra.io
Tristanto
@rustyworks
Aug 02 2015 07:38
@StIvEk I still got wrong answer :( Here is piece of my code (I try hardcoded for the third parameters)
      console.log(2 * Math.PI * Math.pow((Math.pow(35873.5553 + earthRadius), 3) / GM, 0.5));
John Chau
@ydjjabt
Aug 02 2015 07:40
@annchichi
u finish yet?
lol
easi
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:40
@rustyworks use Math.sqrt() instead of Math.pow( ..., 0.5)
John Chau
@ydjjabt
Aug 02 2015 07:41
ok u working too hard guy
Ketan Bhatt
@ketanbhatt
Aug 02 2015 07:41
@ydjjabt ya so in order to pair program I should either move to windows, believe me, I had rather die
John Chau
@ydjjabt
Aug 02 2015 07:41
@ketanbhatt lol
Ketan Bhatt
@ketanbhatt
Aug 02 2015 07:41
@ydjjabt or buy a mac, oh how much i wish i could afford that :D
John Chau
@ydjjabt
Aug 02 2015 07:41
well i got a $100 lenovo cheap computer running window7
annchichi
@annchichi
Aug 02 2015 07:41
@ydjjabt yeah I actually went through the problem. But I don’t think I get fully undesrstand where I should put the ‘return’. :S rrrrr
John Chau
@ydjjabt
Aug 02 2015 07:41
ur logic is completely wrong
Ketan Bhatt
@ketanbhatt
Aug 02 2015 07:41
kobra and teamviewer then! :D @StIvEk @SojournerOctocat thanks!
John Chau
@ydjjabt
Aug 02 2015 07:42
@annchichi u have a pet?
Ketan Bhatt
@ketanbhatt
Aug 02 2015 07:42
@ydjjabt even I have a dual booted system (for those rare MS Word files)
annchichi
@annchichi
Aug 02 2015 07:42
@ydjjabt no eh.
John Chau
@ydjjabt
Aug 02 2015 07:43
@annchichi basically u go from i = 0 to whatever i is and if 2 to the power of that i equal the number input, then u return true and stop going up in the i????right?
look at ur code, it very easy
ok the reason i ask u have pet or not is, if u have a pet, dont u wish ur pet talk back to u if u ask ur pet a question
computer programming is like that
u dont want to program the whole thing
u only program one thing and expect the computer to answer that one thing
that way u r sure it understand what u program
so that the big secret
now can u tell me how u suppose to mkae the computer talk back to u and the computer can talk back to u
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:45
@annchichi if you want to exit the loop when result = num or when result > num then it is better to use while loop insted of for loop
John Chau
@ydjjabt
Aug 02 2015 07:45
@StIvEk for and while are the same in this case
if u want to break the loop once it reach 16 for example, what does i have to be ....look at ur for(...)
just set i = num and it would end because if i = num then it be false and the for loop end
and wont keep going
or u can use the keyword break
i like i better because u will see its power in more future problems
annchichi
@annchichi
Aug 02 2015 07:47
@ydjjabt I get what you are saying. But still though, it when result === num, like you say, it stops. Then why it proceeds to else and return the value of else as false in this case?
Tristanto
@rustyworks
Aug 02 2015 07:48
@StIvEk is a = l / (1 - earthRadius^2) ?
John Chau
@ydjjabt
Aug 02 2015 07:48
ur code doesnt stop when 2 to the power of i equal number say 16
Tristanto
@rustyworks
Aug 02 2015 07:48
It seems I still have wrong answer (NaN) :D
John Chau
@ydjjabt
Aug 02 2015 07:49
2,i=4 equal 16....it wont return true lol....sad but true that it dont return true when i=4 and the number input is 16 because u have to see what the hell the computer interpret ur code
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:49
@rustyworks would you paste your equation here
John Chau
@ydjjabt
Aug 02 2015 07:50
instead it proceed to i = 5 and 2 to the power of 5 not equal 16 and so on and it return false
so u need break
or i = num to stop the for loop
u keep on thinking of solution to small problem u r having right now
Tristanto
@rustyworks
Aug 02 2015 07:51
    function orbitalPeriod() {
      var GM = 398600.4418;
      var earthRadius = 6367.4447;
      var avgAlt = 35873.5553;
      var a = avgAlt / (1 - earthRadius);
      var tmp = Math.pow(a, 3) / GM;
      var res = 2 * Math.PI * Math.sqrt(tmp);
      console.log(2 * Math.PI * Math.sqrt(tmp));
      console.log(res == 86400);
      // return arr;
    }

orbitalPeriod();
Clari
@loveclari
Aug 02 2015 07:51
Can someone check my code?
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:53
@rustyworks it should be: var a = avgAlt + earthRadius;
and you have to round the result in order to compare it to integer
Nic Galluzzo
@ngalluzzo
Aug 02 2015 07:54
@loveclari jquery isn’t included in your code
A_Pen_by_Clari.png
click up there and include any scripts you need
Tristanto
@rustyworks
Aug 02 2015 07:55
@StIvEk Oh I see, Thank you.
Sean Davis
@Fridurmus
Aug 02 2015 07:55
can someone help me diagnose why I get an error with this code, unexpected token/end of input at the end of it?
exports.filter = function (theDir, theExt, callback = function() {

    fs.readdir(theDir, function(err, data){
       if(err){
           //do nothing
       } 
       else{
           for(var i in data){
               if(path.extname(data[i]) === "." + theExt){
                   return data[i];
               }
           }
       }
    })
})
Sergey Zhidkov
@sergey-zhidkov
Aug 02 2015 07:56
is this legal callback = function() {?
Sean Davis
@Fridurmus
Aug 02 2015 07:56
I believe so? This syntax is strange and I don't have any actual examples of it
The IDE doesn't error when I have just the function declaration
Clari
@loveclari
Aug 02 2015 07:57
@ngalluzzo wow
Sean Davis
@Fridurmus
Aug 02 2015 07:57
But all my () {} pairs match
Clari
@loveclari
Aug 02 2015 07:57
Ok that makes sense because is not even showing up
Nic Galluzzo
@ngalluzzo
Aug 02 2015 07:57
yup, same thing with Bootstrap @loveclari . include it in the HTML header instead by clicking the settings for that
Clari
@loveclari
Aug 02 2015 07:57
I really don’t know how to fix this
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:58
@rustyworks you are welcome. Good luck :)
Sergey Zhidkov
@sergey-zhidkov
Aug 02 2015 07:58
My chrome says Uncaught SyntaxError: Unexpected token =
annchichi
@annchichi
Aug 02 2015 07:58
@ydjjabt understood it now. Thanks! ^^
John Chau
@ydjjabt
Aug 02 2015 07:58
@annchichi u solved it?
annchichi
@annchichi
Aug 02 2015 07:59
@ydjjabt yeh, thanks eh. : )
John Chau
@ydjjabt
Aug 02 2015 07:59
hint.if logic and computer doesnt do what u want, by all means try another method
computer always right lol
function PowersofTwo(num) {
  var answer = false;
    for (var i = 0; i<num; i++) {
    var result = Math.pow(2,i);

        if (result === num) {

            answer = true;
            i = num;
        } 

    }
    return answer
}
Stoyan Ekupov
@StIvEk
Aug 02 2015 07:59
This message was deleted
John Chau
@ydjjabt
Aug 02 2015 08:00
function PowersofTwo(num) {
  var answer = false;
    for (var i = 0; i<num; i++) {
    var result = Math.pow(2,i);

        if (result === num) {

            answer = true;
           // i = num;
break;
        } 

    }
    return answer
}
cons
@annchichi what ur answer look like?
Bin Ury
@teddy-error
Aug 02 2015 08:01
@ydjjabt the callback parameter should be whatever method in your code you want to be called to parse the JSON
annchichi
@annchichi
Aug 02 2015 08:02
@ydjjabt the code that I post to you was my answer acutally. It was just that I was ‘guessing’ wher to put return. It bothers me. So I ask you guys. : P
John Chau
@ydjjabt
Aug 02 2015 08:04
@teddy-error hey what the difference between JSON and JSONP?
Clari
@loveclari
Aug 02 2015 08:05
ok @ngalluzzo figuring out
@ngalluzzo thank u sooooo much
Nic Galluzzo
@ngalluzzo
Aug 02 2015 08:05
any time
Sergey Zhidkov
@sergey-zhidkov
Aug 02 2015 08:05
@Fridurmus default parameters supported only in Firefox today, I think node.js doesn't support
Sean Davis
@Fridurmus
Aug 02 2015 08:08
I've got it working, I just need to figure out how you implement a callback function
the node.js tutorial they're using doesn't really explain it well
Tristanto
@rustyworks
Aug 02 2015 08:10
@StIvEk Thank you for your pointer, May I know your FCC Name? I give the credit to you.
Stoyan Ekupov
@StIvEk
Aug 02 2015 08:16
@rustyworks I'm also stivek @FCC :)
Tristanto
@rustyworks
Aug 02 2015 08:16
@StIvEk Thank you, Sir!
John Chau
@ydjjabt
Aug 02 2015 08:17
@Fridurmus it look like u cannot return and end the for loop going through tthe object data lol
Stoyan Ekupov
@StIvEk
Aug 02 2015 08:18
@rustyworks happy to help
evaristoc
@evaristoc
Aug 02 2015 09:18
@Fridurmus In the problem posted above bear in mind that the problem may not be related to your callback per se: it is a syntax issue. I personally hate the excessive use of {}, . and () in JS. Disclaimer: python fan.
articulating
@articulating
Aug 02 2015 09:24
How do I do the DNA bonfire?
Nepherius
@Nepherius
Aug 02 2015 09:36
a simple way is to use switch
a better way is to use keys
articulating
@articulating
Aug 02 2015 09:45
yeah but what is it asking
Nepherius
@Nepherius
Aug 02 2015 09:47
that you complete the pairs
ATC would be AT AT CG
Sean Davis
@Fridurmus
Aug 02 2015 09:48
@evaristoc I think the problem I'm having now is that I just don't quite get the callback structure
If the callback is a function, what am I passing in?
articulating
@articulating
Aug 02 2015 09:51
@Nepherius I think I'll just skip that one for now
Nepherius
@Nepherius
Aug 02 2015 10:07
its quite simple really :)
Dardan Kadrija
@DardanKadrija
Aug 02 2015 10:19
when will beta be launched
George Tsoukatos
@Gts0uk
Aug 02 2015 10:23
guys any help on where I can learn about APIs
so that I can do the Front End Development Projects
quincy doesn't provide a link with APIs
Afroz (zorfa)
@zorfa
Aug 02 2015 11:01
@Gts0uk Check out codecademy : https://www.codecademy.com/apis
cblupodev
@cblupodev
Aug 02 2015 11:20

Working on the Express waypoint
asdf
asdf

var express = require("express"),
    fs = require("fs");
var app = express();

app.listen(process.argv[2]);
app.use(require('stylus').middleware(__dirname + '/public'));
app.use(express.static(process.argv[3] + '/main.css'||path.join(__dirname, 'public'))); // problem line
app.use(express.static(process.argv[3] + '/index.html'||path.join(__dirname, 'public')));

Why the error?

evaristoc
@evaristoc
Aug 02 2015 11:20
@Fridurmus sorry for answering so late... depends of the method the callback is embedded in... in your problem, I think you defined a "callback" when it was not required... but I trend not to assert my comments as I am not a JS ninja at all
@cblupodev I haven't tried this yet but it looks like it is not getting /main.css, suggesting the path is not correctly set
I would suggest a simple console.log(process.argv[3]+'/main.css') to see how the path looks like?
evaristoc
@evaristoc
Aug 02 2015 11:27
the other thing is: you are pointing stylus as middleware located in the public folder, which is usually where the static files are located... I wonder if there is not a sort of confusion about how the statics should looks like...
cblupodev
@cblupodev
Aug 02 2015 11:27
@evaristoc Yeah. I don't get it. When I do console.log(fs.readdirSync(process.argv[3]));
I get
[ 'index.html', 'main.css', 'main.styl' ]
Kameron Robinson
@RobinsonKameron
Aug 02 2015 11:28
I'm available for questions on bonfires 1-18
evaristoc
@evaristoc
Aug 02 2015 11:31
Ok... ask yourself what is process.argv[3] here? If I remember correctly the express.static method requires only the path where to find the static files (usually public)... with that, express knows that any file/folder under that parent folder will be considered static
cblupodev
@cblupodev
Aug 02 2015 11:32
@evaristoc what's the purpose of the .middlware parameter? Am I simply supposed to point to its module or something?
evaristoc
@evaristoc
Aug 02 2015 11:33
And it seems that you need the main.styl, not the css one...
cblupodev
@cblupodev
Aug 02 2015 11:34
@evaristoc This is process.argv[3] /home/ubuntu/.nvm/v0.11.14/lib/node_modules/expressworks/exercises/stylish_css/public
@evaristoc Got the same error when I replaced main.css with main.styl
evaristoc
@evaristoc
Aug 02 2015 11:35
@cblupodev I think in this case you are registering Stylus as an additional "engine" that will translate some of your files into something... Express has default ones: you are maybe been asked to change the default one by another one...
@cblupodev Ok: as you see from above, when you do a fs over process.argv[3] under readdirSync, you are getting the files in the folder... am I correct?
cblupodev
@cblupodev
Aug 02 2015 11:37
@evaristoc correct
evaristoc
@evaristoc
Aug 02 2015 11:42
@cblupodev From what I remember, you should see from which folder you are in to set the cwd when working JS scripts in express. I really don't have a solution right now to your problem but can you try path.join(__dirname, 'public') only? Make a console log of __dirname to see what I mean...
cblupodev
@cblupodev
Aug 02 2015 11:46
@evaristoc whats the "cwd"?
evaristoc
@evaristoc
Aug 02 2015 11:54
current working directory
(python)
@cblupodev how is it?
Babs Craig
@babzcraig
Aug 02 2015 11:58
Hi all, what can I do while waiting for someone to pair with?
evaristoc
@evaristoc
Aug 02 2015 11:58
I will be leaving soon...
@babzcraig you can go for any other challenges you want, there is not an imposed order...
Babs Craig
@babzcraig
Aug 02 2015 11:59
Really? Okay then. Thanks
Aniruddh Agarwal
@anrddh
Aug 02 2015 12:00
It is not compulsory to pair program!
Though it is recommended
evaristoc
@evaristoc
Aug 02 2015 12:01
@cblupodev I am leaving... check what express guides say about middleware method too? I really don't remember (not a web-dev).
People take care!
Spatz
@Spatzerny
Aug 02 2015 12:13
I have a little question: is using 12-col in bootstrap for the header an 'ok' thing to do?
Asked to early: "No grid classes are required for full-width elements"
cblupodev
@cblupodev
Aug 02 2015 13:08

Working on the Express waypoint
asdf
asdf

var express = require("express"),
    fs = require("fs");
var app = express();

app.get('/books', function(req, res) {
  fs.readFile(process.argv[3], function(err, data) {
    res.json(JSON.parse(data));
  })
}).listen(process.argv[2]);

How do I get my response JSON to that long single line?

Dardan Kadrija
@DardanKadrija
Aug 02 2015 13:19
hello I have problem with modulo
can someone help ?
Tristanto
@rustyworks
Aug 02 2015 13:23
@DKadrija Modulo operations is to seek the remainder, while you try to divide. What's wrong with modulo ?
Dardan Kadrija
@DardanKadrija
Aug 02 2015 13:25
23%10 = remainder of 3 so rezult is 3
17%5=4
13%7=8
14%3=6
99%8=3
11%3=6
Tristanto
@rustyworks
Aug 02 2015 13:28
23 / 10 = 2 (and the remainder is 3)
17 / 5 = 3 (and the remainder is 2) --> You should check this
13 / 7 = 1 (and the remainder is 6) --> Check this
14 / 3 = 4 (remainder is 2) --> Check
It's seems the rest is wrong
Dardan Kadrija
@DardanKadrija
Aug 02 2015 13:30
I dont understand the logic now :/
So if we do 23 % 10, we divide 23 by 10 which equals 2 with 3 left over. So 23 % 10 evaluates to 3.
I try to do the same as that ^^ but why I get wrong rezult
DTing
@dting
Aug 02 2015 13:31
@DKadrija x % y is the remainder after you divide x by y
Tristanto
@rustyworks
Aug 02 2015 13:31
@DKadrija Are you do the right things ? I mean check the variable scope, is it global or local ?
Dardan Kadrija
@DardanKadrija
Aug 02 2015 13:32
can you write a formula that I could work with that
Tristanto
@rustyworks
Aug 02 2015 13:33
@DKadrija I think there's no formula, only the expression, and try to write it in developer console.
DTing
@dting
Aug 02 2015 13:34
17/5 = 3.4so you take the int portion of 3.4and do 5 * 3 = 15, 17-15 = 2or you can think of it as 17 - 5 = 12, 12 - 5 = 7, 7 - 5 = 2, can't continue so 17 % 5 = 2
Tristanto
@rustyworks
Aug 02 2015 13:35
^ This ...
Dardan Kadrija
@DardanKadrija
Aug 02 2015 13:35
great thank you
DTing
@dting
Aug 02 2015 13:35
That's for postive values. negative value % is language dependent.
Eko Julianto Salim
@ekojsalim
Aug 02 2015 13:36
yeah
% inn js is really the remainder operator not the modulo operator
Tristanto
@rustyworks
Aug 02 2015 13:37
If your result still incorrect, I think I need to demonstrate using screenhero ;)
Valentina Carraro
@ralentina
Aug 02 2015 13:38
I'm stuck on the pig latin challenge...can someone help me figure out why my code doesn't work?
It passes all tests, a part from translate("glove"), which returns 'gloveay'
function translate(str) {
var newStr;

if(str.charAt(0).match(/[aeiou]/)) {
 newStr = str.concat('way');
 }

 else {

 var firstVow = str.indexOf('a'||'e'||'i'||'o'||'u');
 newStr = str.substring(firstVow) + str.substr(0,firstVow) + 'ay';
 }

 return newStr;
}

translate("consonant");
Dardan Kadrija
@DardanKadrija
Aug 02 2015 13:41
@rustyworks no its fine now
Moisés Man
@moigithub
Aug 02 2015 13:43
@evinrude-xxx str.indexOf('a'||'e'||'i'||'o'||'u'); this dont work just tested on console
but instead that.. u can use this
https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/String/search
Hunter
@retnuh1974
Aug 02 2015 13:45
how do you screenshot your code like that when asking for help?
Tristanto
@rustyworks
Aug 02 2015 13:46
use triple backticks ```
code
and triple backticks again
Hunter
@retnuh1974
Aug 02 2015 13:46
oh
Tristanto
@rustyworks
Aug 02 2015 13:46
@evinrude-xxx is str.substr(0, firstVow) right ? EDITED- Nevermind, you already right
Hunter
@retnuh1974
Aug 02 2015 13:47
test
Tristanto
@rustyworks
Aug 02 2015 13:47

<triple backticks> <enter>
<code><enter>

<triple backticks>

Hunter
@retnuh1974
Aug 02 2015 13:47
/*jshint multistr:true */

var text = "This is how Stephen does\
this from time to time, but Stephen keeps\
going over and over, Stephen is special.";

var myName = "Stephen";
var hits = [0];

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

    if (text[i] === 'S') {    

       for (var j=myName.length; j>0; j--) {
            hits.push(text[i]);
            i++;
            console.log(hits);
        }
        break;
    }

};
that didnt work lol
Moisés Man
@moigithub
Aug 02 2015 13:48
backticks on its OWN line
u can edit ur post (add some shift+enter)
:clap:
Hunter
@retnuh1974
Aug 02 2015 13:50
ah thanks, but now my enter just keeps breaking to new line, not posting to chat
Moisés Man
@moigithub
Aug 02 2015 13:50
control enter to send...
Hunter
@retnuh1974
Aug 02 2015 13:50
I have to Ctrl + Enter
I didnt have to do that earlier, hmm Okay
Moisés Man
@moigithub
Aug 02 2015 13:51
thats cuz u changed ur "edit mode".. check the icon at ur bottom right side
Jorge Almeida
@Jorgixhallo
Aug 02 2015 13:51
@evinrude-xxx Your var firstVow is returning [1, 1, -1, 0, -1 ]. So that's must be the problem
Hunter
@retnuh1974
Aug 02 2015 13:51
ah cool, thanks
Moisés Man
@moigithub
Aug 02 2015 13:51
compose mode / chat mode
Hunter
@retnuh1974
Aug 02 2015 13:52
so my code above, I am outputting a zero in the beginning of my array "[ 0, 'S', 't', 'e', 'p', 'h', 'e', 'n' ]"
Tristanto
@rustyworks
Aug 02 2015 13:52
@evinrude-xxx @Jorgixhallo and @moigithub is right, I forget to test the indexOf(<condition>)
Hunter
@retnuh1974
Aug 02 2015 13:52
Im here --> Waypoint: Learn JavaScript For Loops
Valentina Carraro
@ralentina
Aug 02 2015 13:52
@moigithub thank you! that was the issue! I changed str.indexOf('a'||'e'||'i'||'o'||'u') to str.search(/[aeiou]/) and it now works!
Moisés Man
@moigithub
Aug 02 2015 13:55
@retnuh1974 i think.. IF u remove ur break.. should work
break ends ur for/loop iteration
also.. lets say... IF u have a text of 10 character length... (on js index start on 0)
so it will go from 0 to 9
for (var i=0; i<=text.length; i++) { u no need <= just <
Hunter
@retnuh1974
Aug 02 2015 13:56
no, the break is keeping just the first set of my name showing up and not the other three
Jorge Almeida
@Jorgixhallo
Aug 02 2015 13:57
@retnuh1974 you're starting with hits=/[0]. And then pushing into the var "hits". won't that give you your output?
Hunter
@retnuh1974
Aug 02 2015 13:58
that was it @Jorgixhallo thanks
var hits = [];
I still have a problem but working through it, but that got rid of the 0. THanks
Jorge Almeida
@Jorgixhallo
Aug 02 2015 14:15
@retnuh1974 fell free to ask if you have any other questions :) But try to solve them first I think RSAP should have that included xD
Hunter
@retnuh1974
Aug 02 2015 14:17
@Jorgixhallo thanks, I spent 30 minutes on it before I asked for help.
and what is RSAP?
Moisés Man
@moigithub
Aug 02 2015 14:23
read search ask post
its explained on one of the bonfires if i recall
Tiago Bernardo
@Tiago-OP
Aug 02 2015 14:23
Hi
how to use console.log on bonfire exercices?
Hunter
@retnuh1974
Aug 02 2015 14:26
well my first question asked on here after I took at least 30 minutes trying figure it out myself and someone asks me to try to solve it on my own first. First question = not good experience
I should say, they said "fell free to ask if you have any other questions :smile: But try to solve them first"
Tiago Bernardo
@Tiago-OP
Aug 02 2015 14:31
thanks
Spatz
@Spatzerny
Aug 02 2015 14:41
It seems that the more people are actually on this chat the less helpful it is...
:P
Oliver
@Dadsaster
Aug 02 2015 14:49
@Tiago-OP it depends what browser you use. On chrome if you open -> hamburger menu top right -> more tools -> javascript console and you should see any console.logs you write in your code
cblupodev
@cblupodev
Aug 02 2015 14:58
I'm stuck at Getting Set for Basejumps http://www.freecodecamp.com/challenges/waypoint-get-set-for-basejumps
asdf
The xdg-open: no method available for opening 'http://localhost:8080' line didn't appear
George Tsoukatos
@Gts0uk
Aug 02 2015 15:00
any good tutorial on how to use APIs ?
Oliver
@Dadsaster
Aug 02 2015 15:03
@Gts0uk APIs aren't universal. Do you have one in mind?
George Tsoukatos
@Gts0uk
Aug 02 2015 15:04
@Dadsaster the weather one
cblupodev
@cblupodev
Aug 02 2015 15:06
@Gts0uk I know you have to sign up for a free trial, but if you really really want a proper tutorial about cloud APIs. I highly recommend this Lynda course [lynda.com]. He even provides a handy weather example for that zipline you're probably referring to
Oliver
@Dadsaster
Aug 02 2015 15:06
I haven't done the weather one but this looks nice and simple: http://weatherjs.com/
George Tsoukatos
@Gts0uk
Aug 02 2015 15:07
@cblupodev I want to grasp the knowledge of how to use them properly
DTing
@dting
Aug 02 2015 15:08
@cblupodev click the preview button
cblupodev
@cblupodev
Aug 02 2015 15:08
@Gts0uk Well then, that course is a fantastic start. Haven't stumbled upon anything better
George Tsoukatos
@Gts0uk
Aug 02 2015 15:09
@cblupodev thanks man
is it free ?
Oliver
@Dadsaster
Aug 02 2015 15:09
@Gts0uk google REST api tutorial - this is the most common structure for modern APIs - youtube has some good free stuff as well
Samuel Plumppu
@Greenheart
Aug 02 2015 15:10
@Gts0uk This helped me to understand APIs better! : )
cblupodev
@cblupodev
Aug 02 2015 15:10
@Gts0uk Yes, with a ten day free trial
George Tsoukatos
@Gts0uk
Aug 02 2015 15:11
in this course we use APIs with Node.js ?
Jorge Almeida
@Jorgixhallo
Aug 02 2015 15:12
@Gts0uk I think CodeCademy got some APIs tutorials
https://www.codecademy.com/apis
George Tsoukatos
@Gts0uk
Aug 02 2015 15:12
@Dadsaster thx
@cblupodev thx dude
DTing
@dting
Aug 02 2015 15:14
@cblupodev try grunt serve again
in the right tab
Moisés Man
@moigithub
Aug 02 2015 15:14
@cblupodev u getting error there
did u run..
bower install && npm install
seems u missing something
DTing
@dting
Aug 02 2015 15:15
oh wait
ya you need bower install && npm install
you probably got a partial install because the cloud9 vm ran out of ram
cblupodev
@cblupodev
Aug 02 2015 15:16
@dting asdf
DTing
@dting
Aug 02 2015 15:17
no npm install will install the packages listed in the package.json
bower install will install the packages listed in bower.json
George Tsoukatos
@Gts0uk
Aug 02 2015 15:17
what is bower ?
if you dont mind me asking
Moisés Man
@moigithub
Aug 02 2015 15:17
bower and npm are package installers....
runinng bower install && npm install they will read a config file..
and install a list of modules
George Tsoukatos
@Gts0uk
Aug 02 2015 15:17
I know npm
is node.js
DTing
@dting
Aug 02 2015 15:18
bower is package manager also
George Tsoukatos
@Gts0uk
Aug 02 2015 15:18
aha
what about homebrew ?
DTing
@dting
Aug 02 2015 15:18
used for front end stuff
Mohit Tomar
@mohittzomar
Aug 02 2015 15:18
Hi guys need some clarification. I am at "Waypoint: Mobile Responsive Images" and I am trying out what learn with a copy of the same file(code) on my computer.
Somehow the bootstrap resizing does not work in my browser from html files. What could be the reason?
'<img class="img-responsive" src="http://bit.ly/fcc-kittens2" alt='three cats'/>'
cblupodev
@cblupodev
Aug 02 2015 15:18
@moigithub @dting They were run before. The yellow warning signs in the left pannel are the results of npm install
George Tsoukatos
@Gts0uk
Aug 02 2015 15:18
brew
DTing
@dting
Aug 02 2015 15:19
@cblupodev those images are too small cant see what that says
cblupodev
@cblupodev
Aug 02 2015 15:19
@dting try dragging the image up to the top of your browser window, next to your current tab
DTing
@dting
Aug 02 2015 15:20
@cblupodev k i'll take a look. I hated cloud9 so i just did all my projects locally.
Moisés Man
@moigithub
Aug 02 2015 15:21
Warning: Loading "babel.js" task... ERROR
>> Error: Cannot find module 'loadash/lang/isFunction'

Aborted ..
@cblupodev run again
bower install && npm install
DTing
@dting
Aug 02 2015 15:24
I think i've had that problem before... And npm and bower installing again didnt help. What i did to fix it was rm -rf node_modules and rm -rf app/client/bower_components then run the bower install && npm install again
cblupodev
@cblupodev
Aug 02 2015 15:25
@dting It's thinking ...
DTing
@dting
Aug 02 2015 15:26
your vm probably crashed while installing the npm modules and it bugged out and thinks that lodash installed correctly when it is still missing some of the folders.
Ya, I just followed the instructions on that getting started page and it seems to work fine
cblupodev
@cblupodev
Aug 02 2015 15:31
DTing
@dting
Aug 02 2015 15:34
@cblupodev ya. does grunt serve still not work?
cblupodev
@cblupodev
Aug 02 2015 15:35
@dting still not working
Moisés Man
@moigithub
Aug 02 2015 15:35
@cblupodev u can run
bower install && npm install
as many times as u like.. it will check the .json files and install whatever is not installed
if everything is already installed it will do NOthing
DTing
@dting
Aug 02 2015 15:36
@moigithub he did. didnt fix it.
@cblupodev my suggestion is to just delete that vm and start over. not sure what's wrong but might not be worth your time to figure it out.
cblupodev
@cblupodev
Aug 02 2015 15:36
@dting @moigithub
cblupo@basejump:~/workspace $ bower install && npm install
cblupo@basejump:~/workspace $ 
@dting yeah. already doing this. Thanks guys
cblupodev
@cblupodev
Aug 02 2015 15:51
Where is the 'Add-on services' button in cloud9? asfd
Alex
@awulkan
Aug 02 2015 16:23
Does anyone have time to help me with the "Seek and Destroy" bonfire? I understand what to do, but I don't know how to make it dynamic.
how do u return the largest num of each array?
Jorge Almeida
@Jorgixhallo
Aug 02 2015 16:27
@AlexWulkan you're talking about Search and Replace bonfire?
Alex
@awulkan
Aug 02 2015 16:27
@Jorgixhallo No
Seek and Destroy
This message was deleted
TJ Martin
@tmartin2089
Aug 02 2015 16:29
@Francozt01 start small
can you think of a way to return the first index of every array?
Franco Zapata
@Francozt01
Aug 02 2015 16:30
let me try it and see what i can do
Abdul R. Taleb-Agha
@atalebagha
Aug 02 2015 16:30
Hi All I’m on Bonfire: Sum up all primes. The first 2 tests work but the third one is off by 23
Here is my code. Any help will be greatly appreciated:
function sumPrimes(num) {
  var array = [];
  var total = 0;
  for (var x = 2; x <= num; x++) {
    for (var y = 2; y <= num; y++) {
      if (x == y) { continue; }
      if (x % y === 0) { break; }
      if (y == num) { array.push(x); }
    }
  }

  for (var i = 0; i < array.length; i++) {
    total = total + array[i];
  }
  return total;
}
Alex
@awulkan
Aug 02 2015 16:30
@Francozt01 If you're stuck for long enough I can send you a link to how I solved it.
TJ Martin
@tmartin2089
Aug 02 2015 16:31
if you can get access to the first index of each, that means you can access every array
then you only need to figure out a way to find the largest of each
Jorge Almeida
@Jorgixhallo
Aug 02 2015 16:31
@AlexWulkan What's your problem with the bonfire exactly? Have you tried to implement anything yet?
Franco Zapata
@Francozt01
Aug 02 2015 16:32
@AlexWulkan ok let me try first, if i see that it takes too long i'll send you
Alex
@awulkan
Aug 02 2015 16:32
@Jorgixhallo I solved it, but my solution is hardcoded and won't work in all cases.
Franco Zapata
@Francozt01
Aug 02 2015 16:32
@tmartin2089 thanks for the advices
Alex
@awulkan
Aug 02 2015 16:32
@Jorgixhallo
function destroyer(arr) {

  var arg = [];
  // Fills arg with arguments[1], arguments[2], arguments[n]
  // How can I make this dynamic? Do I even need it?
  for(var i = 1; i < arguments.length; i++){
    arg.push(arguments[i]);
  }

  var survived = arguments[0].filter(function(value, index){

    // Hardcoded what to check. How can I make it dynamic?
    return value != arg[0] && value != arg[1];
  });
  return survived;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
jovandamjanovic
@jovandamjanovic
Aug 02 2015 16:32
@atalebagha I'm not quite certain but it seems like you are testing all your numbers against all the other numbers in both loops... is this intentional?
TJ Martin
@tmartin2089
Aug 02 2015 16:33
@Francozt01 no problem. just break everything down into small steps and you'll be amazed how easy it is to solve
Tristanto
@rustyworks
Aug 02 2015 16:34
@atalebagha just whiteboxing test -> what if 2 == 2 ? does it continue, or it appended to array?
@atalebagha The second is just like said @jovandamjanovic
Rishi Vasandani
@rvasandani
Aug 02 2015 16:37
Hi all, is there a bug with bonfire #22: Search and Replace? The function is supposed to preserve the case of the strings. Here's an example of what it tests for; expect(replace("He is Sleeping on the couch", "Sleeping", "sitting")).to.equal("He is Sitting on the couch");expected 'He is sitting on the couch' to equal 'He is Sitting on the couch'
notice the 3rd argument in the test is "sitting" and not "Sitting". The test however, checks for "Sitting" and not "sitting"
DTing
@dting
Aug 02 2015 16:44
@rii9 Thats what it means by preserving the case.
It wants you to preserve the case of the match, not the replacement.
Jelani Thompson
@JelaniThompson
Aug 02 2015 16:48
Hey does anyone know why this code isn't working for the repeat a string bonfire?
function repeat(str, num) {
  var string = str;
  var number = num;

  for (var i = 0; i < number; i += 1) {
    console.log(string);
  }

  if (number < 0) {
    //Return the empty string
    console.log('');
  }

  return string;
}

repeat('abc', 3);
It's only outputting "abc"
Here's the link to the bonfire also
Tristanto
@rustyworks
Aug 02 2015 16:49
You should return the string, not console.log it @JelaniThompson :)
Rishi Vasandani
@rvasandani
Aug 02 2015 16:52
@dting Ah, thank you!
Jelani Thompson
@JelaniThompson
Aug 02 2015 16:54
Hmm, odd. Still getting this error:
assert.strictEqual(repeat('*', 3), '***', 'should repeat a string n times');should repeat a string n times: expected '*' to equal '***'
Tristanto
@rustyworks
Aug 02 2015 16:55
@JelaniThompson you should appending the string and then return it.
Alex
@awulkan
Aug 02 2015 16:57
@JelaniThompson Your function doesn't actually do anything. It just prints stuff to the console.
Tristanto
@rustyworks
Aug 02 2015 17:00
Anyone, any other way to add prototype function in javascript like this:
function predefinedFunction() {
    doSomething; 
};
myClass.prototype.func = predefinedFunction;
not like this...
Tristanto
@rustyworks
Aug 02 2015 17:07
myClass.prototype.func = function() {
    doSomething;
}
Halp ?
Robert
@rc242
Aug 02 2015 17:11
you mean other than using the prototype property?
Tristanto
@rustyworks
Aug 02 2015 17:13
@rc242 No, but using the predefinedFunction, not anonymous function.
The reason I wan't to do this, is to create new "extended-method" for built ins function like objects and array in javascript
Feners4
@Feners4
Aug 02 2015 17:18
anyone here that can help me with jade and angular?
Robert
@rc242
Aug 02 2015 17:18
@rustyworks couldn't you assign it as part of the myClass definition and use the myClass as a decorator of foo builtin obj?
@Feners4 if you have a question, i would just ask it. if someone knows, they'll answer.
Tristanto
@rustyworks
Aug 02 2015 17:21
I can, hmm ... maybe I should give one example:
I have 2 files, one is the class collections, and one is the method collections.
I want my add my class behavior while adding the method collections.
So rather than I copying one by one the method code inside class, I prefer add the third file: the implementation
which is like my example before: myClass.prototype.func = predefinedFunction;
Robert
@rc242
Aug 02 2015 17:28
@rustyworks if you're looking for a way to remove repetition. You could have a base class Foo, set all your methods on that Foo, and let all of your other classes have a prototype of Foo.
Tristanto
@rustyworks
Aug 02 2015 17:29
Oh, I got it, using Object.create. Thanks @rc242
Jelani Thompson
@JelaniThompson
Aug 02 2015 17:33
Thanks @AlexWulkan :)
Your tip in the DM helped a lot, however this still isn't passing:
function repeat(str, num) {
  if (num < 0) {
    return str;
  } else if (num > 0) {
    var stringRepeat = "";
    //Use the loop to limit how many times it repeats
    for (var i = 0; i < num; i++) {
      stringRepeat += str;
    }
  }
  return stringRepeat;
}
repeat('abc', 3);
It's repeating abc three times like instructed, but now it wants me to return an empty string for negative numbers
I thought that that's what the beginning if statement did, however it still isn't passing
Anyone know what might be wrong?
Nevermind, got it haha
I just realized it said str and not return '';
I had no idea you could return an empty string like that LOL
Fabio Mello
@makall
Aug 02 2015 17:36
@JelaniThompson I don't know the problem, but if num === 0 the the function will return null
Luis Felipe López G.
@luishendrix92
Aug 02 2015 18:05
Has anyone tried the new curriculum in the Beta site (FCC)?
Davyd23
@Davyd23
Aug 02 2015 18:06
hello , did anyone else had a problem with "Bonfire: Symmetric Difference" ? I think it has a problem within the test cases
Feners4
@Feners4
Aug 02 2015 18:12
any help with why my data is not displaying?! http://codepen.io/Feners4/pen/EjONEe
Rex Schrader
@SaintPeter
Aug 02 2015 18:13
@Davyd23 There is not a problem with the test cases. Here, watch this:
https://www.youtube.com/watch?v=PxffSUQRkG4
@Feners4 Your problem is that you need to use "JSONP" not "JSON"
Feners4
@Feners4
Aug 02 2015 18:15
@SaintPeter how so?
Rex Schrader
@SaintPeter
Aug 02 2015 18:15
@Feners4 In the context of this issue, just append this to your api URL: &callback=?
@Feners4 It's complicated. Basically, when you're pulling data from another domain you can't just grab the data. You have to encapsulate it in a callback function. The good news is that jQuery handles most of it for you if you do what I said above
Feners4
@Feners4
Aug 02 2015 18:16
@SaintPeter Ahhh! I see..
Rex Schrader
@SaintPeter
Aug 02 2015 18:17
@Feners4 Humm it looks like you're already doing that? I'm seeing multiple $.getJSON calls, wading through it.
Feners4
@Feners4
Aug 02 2015 18:18
yeah! I was confused for a minute there..
@SaintPeter so then I shouldnt use $getJSON?
Rex Schrader
@SaintPeter
Aug 02 2015 18:19
one moment
I think I see another issue
$.getJSON(url, function() {}).done(function(data) {
That's wrong, I think. I'm pretty sure that the .done callback doesn't include the data.
You need to do this:
$.getJSON(url, function(data) { /* data processing here */ });
That second parameter is the success callback function
Feners4
@Feners4
Aug 02 2015 18:22
@SaintPeter mmmm, ok let me try..
This message was deleted
still nothing..
Davyd23
@Davyd23
Aug 02 2015 18:24
@SaintPeter , if you look at test cases two and three you will see 5 being contained in all 3 arrays passed so the result shouldn't contain 5 , but the program asks that 5 being contained in the resulting array
Feners4
@Feners4
Aug 02 2015 18:25
@SaintPeter
$.getJSON(url, function(data) {
            $scope.getdata.push([username, data, false]);
            count--;
            if (count === 0) {
              $scope.getdata = $scope.getdata.sort();
            }
          });
        } else {
          $scope.getdata.push([username, data, true]);
          count--;
          if (count === 0) {
            $scope.getdata = $scope.getdata.sort();
          }
       angular.forEach($scope.getdata,function(value,index){
                $scope.name = value[0];
         console.log($scope.name);
            })

        }
    })
Rex Schrader
@SaintPeter
Aug 02 2015 18:25
@Davyd23 Did you watch the video? You have to do A and B, then take the result and compare it against C, which means that 5 in the output is correct
@Feners4 According to my console log stuff, it looks like your are actually getting data back. Let me take a look at your angular.
Abhisek Pattnaik
@abhisekp
Aug 02 2015 18:26
I've completed Bonfire up to Bonfire: Find the Longest Word in a String
Have you completed up to that? If you've have please private message me, I want to see how you've done them which might give me some insights into writing better code.
Just ping me, I'll check them in your profile.
Feners4
@Feners4
Aug 02 2015 18:26
@SaintPeter Yeah i have been getting my data..
@SaintPeter I thought my problem was with angular..
Davyd23
@Davyd23
Aug 02 2015 18:28
@SaintPeter I got it , thanks for your help :), and if I can disturb for another question , how do you handle not knowing how many parameters will be called with the function ? for exemple (sum(2,3) and sum(2,3,4))
Rex Schrader
@SaintPeter
Aug 02 2015 18:28
@Davyd23 Use the arguments object.
@Feners4 I guess I needed to ask what you thought the issue was. Why are you doing the angular.forEach?
Davyd23
@Davyd23
Aug 02 2015 18:30
@SaintPeter got it , thanks for your help
Feners4
@Feners4
Aug 02 2015 18:30
@SaintPeter honestly I've been trying so many things to get this to work that I started doing that to get my names and see if it would work in terms of finally displaying..
Rex Schrader
@SaintPeter
Aug 02 2015 18:30
@Feners4 I'm afraid I'm not up to snuff enough on Angular to help you debug. Gotta get. Sorry.
cblupodev
@cblupodev
Aug 02 2015 18:35

I'm stuck at 47 for "Get Set for Basejumps"

asdf

cblupo@basejump3:~/workspace $ yo angular-fullstack:heroku
Error angular-fullstack:heroku 

You don't seem to have a generator with the name angular-fullstack:heroku installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 0 registered generators run yo with the `--help` option.

Video capture of how I got to this point --> [drive.google.com]

cblupo@basejump3:~/workspace $ npm search yeoman-generator
npm WARN Building the local index for the first time, please be patient
Killed
Carl Springer
@haironfire
Aug 02 2015 18:39
I am stuck on Waypoint 67, Mobile Responsive Images. I added the new IMG and specified the .image-responsive class. No go.
Omar
@oab00
Aug 02 2015 18:43
@cblupodev try installing it again
npm install -g generator-angular-fullstack
thereal-bond
@thereal-bond
Aug 02 2015 18:48
Hi everyone!
Anyone else get completely stuck when the waypoints went to jQuery? It seems like the switch to codeacademy's curriculum wasn't well thought out. They're using a bunch of terminology that hasn't been covered yet.
Justin Scoggin
@jscogg
Aug 02 2015 18:49
Working on the Where art thou bonfire. It wants an array that has only objects from the collection that are exactly the same, right?
Jorge Almeida
@Jorgixhallo
Aug 02 2015 18:52
@thereal-bond I don't think you should have problems when switching to codeacademy's because that's an full course and you shouldn't need that much information about other languages. But if you are having difficulties, try to make HTML & CSS course from codecademy
https://www.codecademy.com/courses/web-beginner-en-HZA3b/0/1?curriculum_id=50579fb998b470000202dc8b
Omar
@oab00
Aug 02 2015 18:52
@thereal-bond if you really want you can try the beta for freecodecamp it has a bunch of home made jQuery waypoints instead of using codeacademy
your progress there may or may not be saved to the main site
Arthur Kamst
@arthurkamst
Aug 02 2015 18:53
@thereal-bond yes I have. I just went back to the Codecademy site and did the css selectors part (if I recall correctly that was what I was stuck with)
thereal-bond
@thereal-bond
Aug 02 2015 18:53
Good tips, thanks! It just seemed like CodeAcademy was using a bunch of terminology that it expected me to know, but which freecodecamp hadn't covered
Robert
@rc242
Aug 02 2015 18:53
@haironfire Do you have the wrong name? Paste your code, and it may be easier to help.
thereal-bond
@thereal-bond
Aug 02 2015 18:53
thanks @Jorgixhallo @oab00 and @arthurkamst !
Robert
@rc242
Aug 02 2015 18:54
@haironfire the right value is "img-responsive" not ".image-responsive"
evaristoc
@evaristoc
Aug 02 2015 19:01
@Feners4 hi, looking at your code... why in the first place are you using a jQuery get.JSON call instead of an angular $http?
@cblupodev have you installed the generator for angular? What are you using for installations?
ronald
@ronstarcool
Aug 02 2015 19:02
@rc242 i'm at the same exercise. it works fine, but I dont know how. this "img-responsive" does that work out of the box?? no need the import bootstrap somewhere? seems a little bit to much magic to me. so easy.
evaristoc
@evaristoc
Aug 02 2015 19:03
@cblupodev ... and yeoman
Jelani Thompson
@JelaniThompson
Aug 02 2015 19:04
Hey does anyone here know why this code isn't working for the "Truncate a String" bonfire?
This message was deleted
function truncate(str, num) {

  var truncated_string;

  if (str.length > num) {
   truncated_string = str.slice(0, -3);
   truncated_string += "...";
  }

  return truncated_string;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
It does exactly what the questions asks it to do
Here's a link btw
cblupodev
@cblupodev
Aug 02 2015 19:05
@evaristoc sorry for delay. I got it figured
evaristoc
@evaristoc
Aug 02 2015 19:06
@cblupodev what was it? I am doing all of that my own without haven't seen the Basejump challenges yet... maybe it would be useful to know...
Moisés Man
@moigithub
Aug 02 2015 19:06
@JelaniThompson what IF str.length is NOT > num ?? example
truncate("hello", 100);
ronald
@ronstarcool
Aug 02 2015 19:06
or someone else.. how does bootstrap ajust the picture, kitten-picture 2. you give the picture a class, and thats it. I dont understand how something like that can work. I see no class in the <style></style> area
Justin Scoggin
@jscogg
Aug 02 2015 19:07

Okay, so still on Where art thou... here's what I've got:

function where(collection, source) {
  var arr = [];
  // What's in a name?
  for (i = 0; i < collection.length; i++) {
      if (collection[i].hasOwnProperty(Object.keys(source))) {
          arr.push(collection[i]);
      }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

This passes the second test, but not the first. Ideas?

ronald
@ronstarcool
Aug 02 2015 19:08
other Q: what does the star do, in the top right of this screen?
Moisés Man
@moigithub
Aug 02 2015 19:08
@jscogg u also need to check IF have the same value....
@ronstarcool move the channel on top (left side )
ronald
@ronstarcool
Aug 02 2015 19:09
thanks
Mark
@newbienoob
Aug 02 2015 19:09

Waypoint: Build an Adventure Game. Choose Your Own Adventure! 4/7.
i dont get the goal to this and i keep getting "Oops, try again. Do you want to race Bieber on stage?"

```

ronald
@ronstarcool
Aug 02 2015 19:09
ah, its like the one from codecademy probably
cool game :P
Mark
@newbienoob
Aug 02 2015 19:09
confirm("I am ready to play.");

var age = prompt("What's your age");

if ( age < 13) {
    console.log("You are allowed to play, but i bare no responsibility");
} else {
    console.log("Time to play!");   
}

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");

var userAnswer = prompt("Do you want to race Bieber on Stage?");

if (userAnswer === "yes") {
    console.log("Let's see what you got.")
} else {
    console.log("Who wants to race me?")
}
Justin Scoggin
@jscogg
Aug 02 2015 19:09
@moigithub So && has same value
ronald
@ronstarcool
Aug 02 2015 19:11
link?
Omar
@oab00
Aug 02 2015 19:11
@JelaniThompson you're truncating only last 3 letters while it's asking to truncate everything above the length given
Moisés Man
@moigithub
Aug 02 2015 19:12

@jscogg ?? an object element have 2 parts.. { key : value }
u checking if hasOwnProperty

@jscogg u also need to check IF have the same value....

Justin Scoggin
@jscogg
Aug 02 2015 19:13
@moigithub So hasOwnProperty only checks the key, right?
Moisés Man
@moigithub
Aug 02 2015 19:13
ys
Justin Scoggin
@jscogg
Aug 02 2015 19:13
so is there a method to check val?
Moisés Man
@moigithub
Aug 02 2015 19:15
myobj={"a": 1}
myobj["a"]  === myobj.a
//bracket           dot
// notations
Justin Scoggin
@jscogg
Aug 02 2015 19:16
Ah I see what you're getting at.
I think...
:confused:
Jelani Thompson
@JelaniThompson
Aug 02 2015 19:20
Hmm, is this what you guys were trying to get at? If it is, FCC still isn't accepting it
function truncate(str, num) {

  var truncated_string;

  if (str.length > num) {
   truncated_string = str.slice(0, - num);
   truncated_string += "...";
  }

  return truncated_string;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
Would anyone care to clarify the instructions please? It would be greatly appreciated :D
Thanks!
Luis Felipe López G.
@luishendrix92
Aug 02 2015 19:21
This message was deleted
Moisés Man
@moigithub
Aug 02 2015 19:22
@JelaniThompson from this big string "A-tisket a-tasket A green and yellow basket"
u only need to return 11 characters counting the 3 dots
"A-tisket..."
ofc 11 is an example.. it can vary....
Chad Kreutzer
@ChadKreutzer
Aug 02 2015 19:22
@JelaniThompson lol. @moigithub beat me to it: the three dots count toward your total.
Sonny Rodriguez
@sonnytron
Aug 02 2015 19:24
could use some help modifying a CSS element using an if loop in javascript and indexOf
what I want to do is: check if an element contains a string using indexOf. for example
Moisés Man
@moigithub
Aug 02 2015 19:25
if ( mystring.indexOf( containsThis) > -1 ) {
/// do something
}
Robert
@rc242
Aug 02 2015 19:25
@JelaniThompson I suggest reading: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice. In particular, read the "Parameters" section.
Vlad Zamfirescu
@vzamfirescu
Aug 02 2015 19:25
@sonnytron indexOf will only help you to check individual characters - thus, you could build an indexOf solution by checking consecutive characters, but it is not recommended
Jelani Thompson
@JelaniThompson
Aug 02 2015 19:25
Oh thanks!
So would something like this be better perhaps?
Sonny Rodriguez
@sonnytron
Aug 02 2015 19:25
if ($('#html').indexOf('donuts') !== -1) {
do stuff with donuts
}
Jelani Thompson
@JelaniThompson
Aug 02 2015 19:25
   truncated_string = str.slice(0, - str.length + num - 3);
With the 3 being for the last 3 dots
Robert
@rc242
Aug 02 2015 19:28
@JelaniThompson I suppose that will work, but unnecessary.
Moisés Man
@moigithub
Aug 02 2015 19:28
@sonnytron this is a selector
$('#html')
this return an object...
probably u wanna check its CONTENT... using html() or text() functions
and then.. check if that text "contains" donuts
Sonny Rodriguez
@sonnytron
Aug 02 2015 19:28
so how should i do it @vzamfirescu ? if i want to see if an element, for example in the free weather app zipline, i want to see if the weather conditions have "clouds" in the description?
Moisés Man
@moigithub
Aug 02 2015 19:31
instead using jquery to access the html dom objects...
i suppose u using an API to get that data... so u can just direct check that data (no need jquery)
ur data object.. i suppose.. have properties
description, temperature etc...
so use it...
if (data["description"].indexOf('donuts') !== -1) {
//$("#container").css( .... );
}
Feners4
@Feners4
Aug 02 2015 19:35
@evaristoc ummm, it was the way I was more familiar with..
Moisés Man
@moigithub
Aug 02 2015 19:35
@JelaniThompson
"hello world".slice(0,5); //<--- returns hello
Jelani Thompson
@JelaniThompson
Aug 02 2015 19:36
Oh, so I don't need the -?
Robert
@rc242
Aug 02 2015 19:37
@JelaniThompson Again, I would recommend going to the link I gave you and read what happens when you give slice a negative number.
Moisés Man
@moigithub
Aug 02 2015 19:38
u only need to pick "num" characters... -3 (cuz u including 3 dots)
Clayton
@cjg040103
Aug 02 2015 20:07
Hey, guys! Just got back from a trip 2 our friend's lake house :smile: Good 2 be home!
chasedelong87
@chasedelong87
Aug 02 2015 20:16
Anyone
Can any one help me in the right direction for "what's in s name#? I'm lost on what I need to run keys on and hasOwnProperty. What type is the input?
Sorry for typos. I'm on my cell
John Chau
@ydjjabt
Aug 02 2015 20:20
$.get("https://api.twitch.tv/kraken/user",getCallback,"jsonp")

function getCallback(result){
  console.log(result)
}
how do i get a list of users on Twitch.tv
Vincenzo Pandolfo
@vincepandolfo
Aug 02 2015 20:29
@ydjjabt I don't think you can get a list of ALL users I think
John Chau
@ydjjabt
Aug 02 2015 20:30
@vincepandolfo have u look at the zipline TWitch? it seem like u need a list of total user, a list of online user, and a list of offline user
Vincenzo Pandolfo
@vincepandolfo
Aug 02 2015 20:30
@ydjjabt yup I did it. They also give you a list of usernames
John Chau
@ydjjabt
Aug 02 2015 20:31

@vincepandolfo so correct my mistake in the ```
$.get("https://api.twitch.tv/kraken/user",getCallback,"jsonp")

function getCallback(result){
console.log(result)
}
```

@vincepandolfo how u get a list of usernames
Vincenzo Pandolfo
@vincepandolfo
Aug 02 2015 20:31
@ydjjabt It's in the Zipline page
@ydjjabt look at the hints
John Chau
@ydjjabt
Aug 02 2015 20:32
@vincepandolfo k
Vincenzo Pandolfo
@vincepandolfo
Aug 02 2015 20:32
Then you can do a query to the api for each user
SojournerOctocat
@SojournerOctocat
Aug 02 2015 20:54
How do I get JavaScript to return undefined?
ronald
@ronstarcool
Aug 02 2015 20:56
help. al the white pop-ups from messages are blocking my learn/waypoint screen. what should i do?
Anthony MacMahon
@SansPulp
Aug 02 2015 21:14
Did anyone find a way to use str.split or a for loop to do the Title Case a Sentence bonfire? I found a really elegant solution on stack overflow using function(txt) and txt.substr, but I never would have figured that out on my own. Is there some way to do it by making an array?
YEAMA
@YEAMA
Aug 02 2015 21:15
I am suck here on Bonfire: make a person without knowing why my code doesn't execute to all of the tests ?!
var Person = function(firstAndLast) {
  this.setFirstName = function(first){
    this.firstName = first; 
  } ;
  this.setLastName = function(last){
    this.lastName = last;
  };
  this.setFullName = function(firstAndLast){
    this.fullName = firstAndLast;
  }; 
  this.getFirstName = function (){
    return this.firstName;
  };
  this.getLastName = function() {
      return this.lastName;
    };
  this.getFullName = function() {
        return this.fullName;
      };
};

var bob = new Person('Bob Ross');
bob.getFullName();
any help please ??!
Tristanto
@rustyworks
Aug 02 2015 21:15
@YEAMA Your firstname, lastname, and fullname is different
I mean, try to use the same member
for example fullname is firstname + lastname
YEAMA
@YEAMA
Aug 02 2015 21:16
@rustyworks I don't understand your point
Tristanto
@rustyworks
Aug 02 2015 21:17
Okay, let me simplify this.
If you use the code like that, when you set the firstname, and you call the fullname, your fullname is not updated
So what you should do is: After setting the first name, make sure your full name is updated
YEAMA
@YEAMA
Aug 02 2015 21:18
it is already set by the setFullName() method
Tristanto
@rustyworks
Aug 02 2015 21:18
I know, but the fullName is stand alone, for example try this test:
var bob = new Person('Bob Ross');
bob.setFullName("Ken Arok");
bob.getFirstName();
Your firstName will return Bob, is it right ?
YEAMA
@YEAMA
Aug 02 2015 21:20
Nope! undefined
Tristanto
@rustyworks
Aug 02 2015 21:20
Bingo, that's it
Jonathan Lee
@Jwing28
Aug 02 2015 21:21
I have a question on that same bonfire myself
Tristanto
@rustyworks
Aug 02 2015 21:21
Your constructor only set the fullname only, not the first and the last @YEAMA
YEAMA
@YEAMA
Aug 02 2015 21:22
@rustyworks but how can I set the firstname and lastname to both the argument passed and this method you saying ??
Jonathan Lee
@Jwing28
Aug 02 2015 21:22
i pass all the tests except the last 3, for example one of the last ones i fail has bob.getFirstName() return 'Happy' but I passed the previous bob.getFirstName() test which was supposed to return 'Bob'
Robert
@rc242
Aug 02 2015 21:22
@rustyworks @YEAMA I'm pretty sure that constructtor does nothing but assign functions.
Tristanto
@rustyworks
Aug 02 2015 21:22
When you passing data to the firstAndFullName, you should assign that value to firstName and lastName as well
Jonathan Lee
@Jwing28
Aug 02 2015 21:22
I don't understand how bob.getFirstName() can return both? i feel like there's something I'm not understanding and don't realize
Tristanto
@rustyworks
Aug 02 2015 21:23
You should add more logic in .setFullName()
@rc242 right, You should add more logic into constructor and setFullName
Jonathan Lee
@Jwing28
Aug 02 2015 21:25
sorry for jumping in just thought I would add my question since i'm stuck on the same bonfire lol
Robert
@rc242
Aug 02 2015 21:26
@Jwing28 Can you be a bit more descriptive? What's the test that's failing?
Tristanto
@rustyworks
Aug 02 2015 21:26
@Jwing28 Can you show us the snippet code ?
Jonathan Lee
@Jwing28
Aug 02 2015 21:26
sure, here are the 3 tests i'm failing
expect(bob.getFirstName()).to.eql('Happy');expected 'Bob' to deeply equal 'Happy'
expect(bob.getLastName()).to.eql('Trees');expected 'Ross' to deeply equal 'Trees'
expect(bob.getFullName()).to.eql('George Carlin');expected 'Bob Ross' to deeply equal 'George Carlin'
okay
var Person = function(firstAndLast) {//person constructor


  this.getFirstName = function () { 
    var split = firstAndLast.split(" ");
    return split[0];
  };

    this.getLastName = function () { 
    var split = firstAndLast.split(" ");
    return split[1];
  };

  this.getFullName = function () { 
    return firstAndLast;
  };

 this.setFirstName = function (first) { 
    this.first = first;
  };

   this.setLastName = function (last) { 
    this.last = last;
  };

   this.setFullName = function (firstAndLast) { 
    this.firstAndLast = firstAndLast;
  };

  //  return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFullName();
YEAMA
@YEAMA
Aug 02 2015 21:29
@Jwing28 your code will always work with the firstAndLast argument and will not return the updated first , last & full names
thats what may it be !!
Tristanto
@rustyworks
Aug 02 2015 21:31
@Jwing28 your problem only in scope, variable scope
You should remember about the scope, if it inside in function, it will be that scope, but if you do not declare it with var, it will be global
Jonathan Lee
@Jwing28
Aug 02 2015 21:32
okay
Tristanto
@rustyworks
Aug 02 2015 21:32
So try to set the first, last, and firstAndLast inside the constructor
hint: you won't need this to do this
ronald
@ronstarcool
Aug 02 2015 21:34
this.fullname = firstandlast;
ur not producing anything right?
Jonathan Lee
@Jwing28
Aug 02 2015 21:35
so i changed the get functions in mine to use this. instead of using split and accessing the array
that had me pass those last 3 tests but i now fail the middle tests
i don't think i get this well enough =/
what i am supposed to accomplish
Tristanto
@rustyworks
Aug 02 2015 21:37
You should care about your variable scope, here is my example:
function (firstAndLastNAme) {
    var firstAndLastName = firstAndLastName;
    var firstName = firstAndLastName.split(' ')[0];
    var lastName = firstAndLastName.split(' ')[1];
}
Why I use local variable instead object.variable (this), because of the first constraint, where the Person class should only have 6 properties
jovandamjanovic
@jovandamjanovic
Aug 02 2015 21:42
It's supposed to have 6 properties: firstName, lastName, fullName should be hidden and three getters and three setters should be exposed. The lesson is focused on encapsulation :)
Tristanto
@rustyworks
Aug 02 2015 21:44
^This ...
Stephanie Keck
@StephanieKeck
Aug 02 2015 21:46
I'm trying to solve the Make A Person Bonfire. If I declare variables in the Person function using var, does that exclude me from accessing them from methods added to Person.prototype using this?
I'm just trying to figure out why my code isn't working.
Tristanto
@rustyworks
Aug 02 2015 21:47
If you declare with var, you should access it without this
jovandamjanovic
@jovandamjanovic
Aug 02 2015 21:47
Can you post some of it? It shouldn't prevent you from accessing them, but the this would be redundant
Tristanto
@rustyworks
Aug 02 2015 21:48
@jovandamjanovic is right
Stephanie Keck
@StephanieKeck
Aug 02 2015 21:48
Here's my code so far:
var Person = function(firstAndLast) {
  var firstName = firstAndLast.split(' ')[0];
  var lastName = firstAndLast.split(' ')[1];
};

Person.prototype.getFirstName = function() {
  return this.firstName;
};
Person.prototype.getLastName = function() {
  return this.lastName;
};
Person.prototype.getFullName = function() {
  return this.firstName + " " + this.lastName;
};

Person.prototype.setFirstName = function(name) {
  this.firstName = name;
};
Person.prototype.setLastName = function(name) {
  this.lastName = name;
};
Person.prototype.setFullName = function(name) {
  this.firstName = name.split(' ')[0];
  this.lastName = name.split(' ')[1];
};

var bob = new Person('Bob Ross');
bob.getFullName();
cboh
@cboh
Aug 02 2015 21:49
i am on bonfire 'reverse a string' and here is whay i have so far. however, i keep getting 'undefined' after i run the code to reverse the string 'hello' to 'olleh'
Tristanto
@rustyworks
Aug 02 2015 21:49
just remove all this.<name> and your problem is gone :-|
jovandamjanovic
@jovandamjanovic
Aug 02 2015 21:49
Or, what I mean to say: by default java functions try to access variables 'within' themselves and if they cant find them there, they seek one step higher in their prototype chain. When you put this as a prefix you're telling the function that a variable -has- to exist within the function and not outside.
Since you declared your vars outside the methods that call them, you should remove the this keyword and it should work.
cboh
@cboh
Aug 02 2015 21:50
blob
Stephanie Keck
@StephanieKeck
Aug 02 2015 21:50
So the prototype knows to look at Person to find its' variables without this?
jovandamjanovic
@jovandamjanovic
Aug 02 2015 21:51
Also, in your code, while it is not wrong to declare methods by extending the prototype, it would be simpler to just declare them within the 'Person' class itself.
It does.
That's the prototype chain's business.
Luis Felipe López G.
@luishendrix92
Aug 02 2015 21:52
@cboh Add the code inside the function, not outside.
jovandamjanovic
@jovandamjanovic
Aug 02 2015 21:52
this is used when you expect there to be several same named variables in different scopes and you want to make sure you're using the right one.
@cboh, you're not doing anything with the string, you're just returning the same string you receive :D
Stephanie Keck
@StephanieKeck
Aug 02 2015 21:53
@jovandamjanovic The Udacity course on OO Javascript emphasized using the prototype object to cut down on memory, which is why I did it that wat
Jonathan Lee
@Jwing28
Aug 02 2015 21:53
wow reading all this makes me think i should go through all the waypoint activities again =(
Luis Felipe López G.
@luishendrix92
Aug 02 2015 21:54
I have a question, I really want to work with áéíóúäëïöüñ and other characters to be treated as valid characters in JS.
Jonathan Lee
@Jwing28
Aug 02 2015 21:54
thanks for the help, i seemed to get it while following the videos and thinking about it, but trying this exercise i couldn't come up with the right way to think about it
jovandamjanovic
@jovandamjanovic
Aug 02 2015 21:54
LIke I said, it is not wrong, it is just simpler for this kind of small bonfire to declare methods inside for readability purposes. Using the prototype, on the other hand, is good practice nods
Stephanie Keck
@StephanieKeck
Aug 02 2015 21:54
var Person = function(firstAndLast) {
  var firstName = firstAndLast.split(' ')[0];
  var lastName = firstAndLast.split(' ')[1];
};

Person.prototype.getFirstName = function() {
  return firstName;
};
Person.prototype.getLastName = function() {
  return lastName;
};
Person.prototype.getFullName = function() {
  return firstName + " " + lastName;
};

Person.prototype.setFirstName = function(name) {
  firstName = name;
};
Person.prototype.setLastName = function(name) {
  lastName = name;
};
Person.prototype.setFullName = function(name) {
  firstName = name.split(' ')[0];
  lastName = name.split(' ')[1];
};

var bob = new Person('Bob Ross');
bob.getFullName();
I'm getting the error, firstName is not defined
Jonathan Lee
@Jwing28
Aug 02 2015 21:56
are there multiple ways to do the make a person bonfire?
or should it be obvious the way to go about this problem?
dc
@dcsan
Aug 02 2015 21:57
we have some bonfire specific chat here:
https://gitter.im/FreeCodeCamp/HelpBonfires
Jonathan Lee
@Jwing28
Aug 02 2015 21:57
just want to know if i should start over and go back to try re-learn things
Robert
@rc242
Aug 02 2015 21:57
@StephanieKeck probably a scope problem.
jovandamjanovic
@jovandamjanovic
Aug 02 2015 21:58
Yeah, sounds like a scope problem, just trying to work it out step by step now
Tristanto
@rustyworks
Aug 02 2015 21:59
@StephanieKeck I ever do using prototype method, but if doesn't allow me pass the first constraint
@StephanieKeck And if you use prototype, the variable you should use is this
@StephanieKeck You should put your method inside the person, not prototyping it
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:01
I think I know the problem
You are declaring the firstName inside the Person function, but the Person.prototype is unable to access it.
Stephanie Keck
@StephanieKeck
Aug 02 2015 22:02
@jovandamjanovic That's what I figured. I guess prototypes can't access private variables.
Juan Martínez
@jbmartinez
Aug 02 2015 22:02
hi everyone!
need help with waypoint Build Web Apps with Express.js
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:03
Just checking at my own solution to try and work it out through the prototype
Robert
@rc242
Aug 02 2015 22:05
@StephanieKeck even if you didn't specify them as private, you'll have a scope issue. As @rustyworks said, you'll need to "attach" it to this "scope"
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:06
Basically, what you should try is something like this:
Person.prototype.setFirstName = function(first) { var firstName = first; this.getFirstName = function() { return firstName; }; };
Jonathan Lee
@Jwing28
Aug 02 2015 22:06
being confused sucks, i think i'll take a break and try again, i'll probably be right back here lol
@jovandamjanovic @rustyworks thanks!
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:06
How do I show a snippet view, again? XD
Robert
@rc242
Aug 02 2015 22:07
three backticks, newline, code, newline, three backticks, send message.
Tristanto
@rustyworks
Aug 02 2015 22:07
@Jwing28 Feel free to ask again :)
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:07
Take note, though, this particular exercise will count the number of keys in Person and will not let you pass with using prototype! You -have- to declare within the object.
Robert
@rc242
Aug 02 2015 22:08
Person.prototype.setFirstName = function(first) { var firstName = first; this.getFirstName = function() { return firstName; }; };
damn, i was hoping that would get formatted.
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:08
  this.setFirstName = function(first) {
    var firstName = first;
    this.getFirstName = function() {
      return firstName;
    };    
  };
Stephanie Keck
@StephanieKeck
Aug 02 2015 22:09
But then wouldn't I have to call setFirstName before getFirstName would work?
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:09
@rc242 ty ^^
Yes. That's why, in the constructor, you don't declare your variables but initializethem through the methods:
  this.setFullName(firstAndLast);
  firstAndLast = firstAndLast.split(" ");
  this.setFirstName(firstAndLast[0]);
  this.setLastName(firstAndLast[1]);
Robert
@rc242
Aug 02 2015 22:10
@StephanieKeck No. You have a constructor that takes the name.
gazzer82
@gazzer82
Aug 02 2015 22:11
Hello all, The thing i've really noticed so far doing the Bonfires is how poor my Math skills are after all these years, any suggestions on ways to improve that alongside this course?
Stephanie Keck
@StephanieKeck
Aug 02 2015 22:11
Ok, thanks for the help!
jovandamjanovic
@jovandamjanovic
Aug 02 2015 22:11
The only way I know of improving math skills is thousands of practice problems XD no short cuts in math :D
There must be some good sites for that...
@StephanieKeck nps, I'm not here often but if I am feel free to ask. And if I'm not, theres always tons of other cool people happy to help ;)
SojournerOctocat
@SojournerOctocat
Aug 02 2015 22:14
@gazzer82 Maybe Khan Academy?
Feners4
@Feners4
Aug 02 2015 22:16
Robert
@rc242
Aug 02 2015 22:16
@gazzer82 You mean general math or algorithms?
Feners4
@Feners4
Aug 02 2015 22:16
My data doesnt display!
gazzer82
@gazzer82
Aug 02 2015 22:17
@rc242 i guess the math behind Algorithm, as in factorising numbers, finding primes, that sort of thing. My general +-/* math is fine.
Thanks @SojournerOctocat i'll check Khan Academy out.
Juan Martínez
@jbmartinez
Aug 02 2015 22:22
anyone can help me with a waypoint?
?
Anne Woods
@rainywoods
Aug 02 2015 22:22
@gazzer82 And I used this for figuring out how to test for prime numbers, https://en.wikipedia.org/wiki/Primality_test
Clayton
@cjg040103
Aug 02 2015 22:23
can anyone tell me what's wrong w/ my syntax?
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
}
function list() {
    var contactsLength = contacts.length;
    for(var i = 0; i < contacts.length; i++)
};
list();
i'm looking @ the list function specifically
Logan Tegman
@ltegman
Aug 02 2015 22:25
@cjg040103 You have the start of a for-loop but no code block for it to execute.
Clayton
@cjg040103
Aug 02 2015 22:25
oh?
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
Robert
@rc242
Aug 02 2015 22:26
@gazzer82 I would also check out youtube and some of the videos MIT puts out.
Clayton
@cjg040103
Aug 02 2015 22:26
k thx
@ltegman
Logan Tegman
@ltegman
Aug 02 2015 22:26
@cjg040103 np :smile:
Clayton
@cjg040103
Aug 02 2015 22:27
what shood i put in between.
?
nevermind... i'll figure it out l8r...
MatiKid
@MatiKid
Aug 02 2015 22:31
I’m really stuck in this Bofire: http://www.freecodecamp.com/challenges/bonfire-sorted-union
Can someone offer a hint?
function unite(arr1, arr2, arr3) {
  var flattened = arr1.concat(arr2, arr3);
  var unique = [];

  return unique;
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);
dc
@dcsan
Aug 02 2015 22:31
bf union
MatiKid
@MatiKid
Aug 02 2015 22:32
I can’t think of a way to delete the duplicates (or push the uniques to an array)
YEAMA
@YEAMA
Aug 02 2015 22:33
@MatiKid you will always add the first array to a (for example) a var result = [] then loop over the other two arrays and add the number that is not found in the result variable
at the end return result;
gazzer82
@gazzer82
Aug 02 2015 22:34
Thanks @rc242 will do, is there a particular channel of anything i should check out?
Robert
@rc242
Aug 02 2015 22:35
@MatiKid You have a couple choices. Minimize space or maximize efficiency. You could also use "brute force", which usually doesn't do either.
oh snap.
@gazzer MIT 6.006 Introduction to Algorithms may be a good start.
gazzer82
@gazzer82
Aug 02 2015 22:38
Thanks @rc242 will check them out!
MatiKid
@MatiKid
Aug 02 2015 22:40
@YEAMA mmmm, think i got it
Dan Morency
@g0shdanit
Aug 02 2015 22:40
anyone remember the build your own rock paper scissors game thing on codecademy?? Well im getting this error but it always tells me the right winner so idk why im getting it? "Oops, try again. Your code returned 'scissors wins' instead of 'undefined' when the inputs are scissors and rock"
Robert
@rc242
Aug 02 2015 22:46
@gazzer82 6.006 has a prereq of 6.042J. Also, you can see perhaps a better organized website at http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/. Make sure to look at the prerequisites to make sure you have the assumed knowledge.
Tom Pyszczuk
@Ne0nite
Aug 02 2015 22:46
erm hey guys/gals :) quick question. I just started with the bonefires. So the first one was to revsres a string. It took me a while to figure out a way to do it but I don't know if thats an optimal way, can somebody look at it and let me know pls :) here is the code:
var stringToSplit = str;
var stringReverse = str.split('').reverse().join('');
var str = stringReverse;
or the whole code:

function reverseString(str) {
var stringToSplit = str;
var stringReverse = str.split('').reverse().join('');
var str = stringReverse;
return str;
}

reverseString('hello');

MatiKid
@MatiKid
Aug 02 2015 22:47
lol, got it
function unite(arr1, arr2, arr3) {
  var flattened = arr1.concat(arr2, arr3);
  var unique = [];

  for(i = 0; i < flattened.length; i++) {
    if(unique.indexOf(flattened[i]) == -1) {
      unique.push(flattened[i]);  
    }
  }

  return unique;
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);
Abdul R. Taleb-Agha
@atalebagha
Aug 02 2015 22:48
Thank you @rustyworks & @jovandamjanovic
MatiKid
@MatiKid
Aug 02 2015 22:52
This message was deleted
Jakob Dahl
@saadanerdetbare
Aug 02 2015 22:52
@Ne0nite you can chain the methods and use them when you return so you dont need more than
return str.split('').reverse().join('');
Tom Pyszczuk
@Ne0nite
Aug 02 2015 22:54
umm heh thats is way simpler.. Thank You. I need to go over this again then :)
@saadanerdetbare :)
Jakob Dahl
@saadanerdetbare
Aug 02 2015 22:54
yw
SojournerOctocat
@SojournerOctocat
Aug 02 2015 22:58
@g0shdanit What's the link/URL to the exercise?
Carl Springer
@haironfire
Aug 02 2015 22:58
Thx @rc242 . That did it.
Juan Martínez
@jbmartinez
Aug 02 2015 22:59
can anyone help me with Build Web Apps with Express.js waypoint?
nvm, I figured out, but I'm not sure if what I did is the right way
Wallace
@wfong1102
Aug 02 2015 23:03
has anyone finished bonfire 38: arguments optional?
I'm having trouble going about it
Juan Martínez
@jbmartinez
Aug 02 2015 23:05
@wfong1102 show your code, please
Wallace
@wfong1102
Aug 02 2015 23:05
all i have so far is
function add() {
if (arguments.length === 2) {
    return arguments[0] + arguments[1];
} else {}
}

add(2,3);
is that even a good way to go about it
Juan Martínez
@jbmartinez
Aug 02 2015 23:06
it's a start
Feners4
@Feners4
Aug 02 2015 23:07
Whyyyyy cant my dataa displayyyyyyyy http://codepen.io/Feners4/pen/EjONEe
Juan Martínez
@jbmartinez
Aug 02 2015 23:07
but what if the second argument is missing?
@Feners4 Hi!
Feners4
@Feners4
Aug 02 2015 23:08
@jbmartinez Hi! still stuck on this lol..
Juan Martínez
@jbmartinez
Aug 02 2015 23:08
I see!
Wallace
@wfong1102
Aug 02 2015 23:08
i thought if it was that case then argument.length < 2 and it would run else
Juan Martínez
@jbmartinez
Aug 02 2015 23:08
let me check, last time I was clueless too
Wallace
@wfong1102
Aug 02 2015 23:08
but i dont really know how to go about having it ask for a second argument
Feners4
@Feners4
Aug 02 2015 23:09
@jbmartinez I made some changes, but idk..
@jbmartinez I think, Im displaying an empty array now, soo some progress maybe?lol
Juan Martínez
@jbmartinez
Aug 02 2015 23:09
@wfong1102 if arguments.lenght === 1 return a function
@Feners4 lol
@Feners4 it seems you're getting the same data multiple time, but that's not the biggest problem
Feners4
@Feners4
Aug 02 2015 23:18
@jbmartinez if my $scope.getdata array is full of arrays.. why wont they even display in my list?
Juan Martínez
@jbmartinez
Aug 02 2015 23:20
@Feners4 can you put your data in objects instead of arrays? I guess it's a lot easier that way:
Luis Felipe López G.
@luishendrix92
Aug 02 2015 23:21
@jbmartinez Arrays have their purpose, objects too. Also, objects can be inside arrays as well as arrays can be values of a given property.
Juan Martínez
@jbmartinez
Aug 02 2015 23:21
@Feners4 now you have a multidimensional array, an array of arrays, try to put it in an array of objects: [{user: something, stream: another}, ...]
@luishendrix92 yes, I know, but objects are a lot easier to display in angular with my limited knowledge :smile:
@Feners4 I guess you can use ng-repeat in a child element of ng-repeat, but that's not very efficient
Dan Morency
@g0shdanit
Aug 02 2015 23:26
@SojournerOctocat figured it out. It was right except i had compare(computerChoice, userChoice) and they wanted compare(userChoice, computerChoice). Picky picky picky! Real code wont care will it?
Juan Martínez
@jbmartinez
Aug 02 2015 23:30
@Feners4 this is strange, you're data is in $scope.getdata but {{getdata.length}} doesn't show anything
Jason Wood
@catapixel
Aug 02 2015 23:30
Anyone out there working through Waypoint: Practice Functional Programming?
Ben
@benflinn
Aug 02 2015 23:31
@catapixel i did for a while - it's really hard! haha.. took me a few tries but i understand about half of it now
Jason Wood
@catapixel
Aug 02 2015 23:33
@benflinn I'm working through it now and I'm running into a problem where after submitting "wrong" solutions a couple times I will start getting a report that concatAll() is not a function. I'm using Chrome and have tried on both Mac and Windows. Can't get around it unless I reset and then "catch up" to where I was. Did you see anything similar?
Juan Martínez
@jbmartinez
Aug 02 2015 23:34
@Feners4 Try not pushing to getdata inside your addData function, return a new array instead and assign it to $scope.getdata. map() is supposed to return a new array after all
m66n
@m66n
Aug 02 2015 23:36
i'm starting "Zipline: Wikipedia Viewer". is it possible to get this effect -- [CodePen] (http://codepen.io/m66n/pen/jPXZbP) -- without using jQuery.animate() and just using CSS transitions and/or animations?
SojournerOctocat
@SojournerOctocat
Aug 02 2015 23:37
@g0shdanit :)
Juan Martínez
@jbmartinez
Aug 02 2015 23:37
@Feners4 yep, just with this change I'm getting something
$scope.getdata = users.map(function(user) {
    addData(user);
  })
@Feners4 try to use an array of objects, though
Feners4
@Feners4
Aug 02 2015 23:40
@jbmartinez sorry, i had to step away , I just read the messages.. let me try..
Juan Martínez
@jbmartinez
Aug 02 2015 23:40
@m66n just with CSS, no js? It'll be tricky, but I guess it can be done
@m66n cool effect, BTW
m66n
@m66n
Aug 02 2015 23:45
@jbmartinez i'm trying to adapt ideas from this site -- http://tympanus.net/codrops/2014/05/12/morphing-buttons-concept/
Feners4
@Feners4
Aug 02 2015 23:53
@jbmartinez jmmm, now im getting: [null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]
Juan Martínez
@jbmartinez
Aug 02 2015 23:53
@m66n great! I'll try to use it in some of my next ziplines
@Feners4 you're getting something now :smile:
Feners4
@Feners4
Aug 02 2015 23:55
@jbmartinez hahah yeah, it seems my data is not saved somehow?
after it loads?
Juan Martínez
@jbmartinez
Aug 02 2015 23:57
@Feners4 change this line: ul#mainMenu {{getdata.length}}, you'll see 15
@Feners4 so, your data has 15 elements, but it's full of nulls
Feners4
@Feners4
Aug 02 2015 23:58
@jbmartinez ujum
@jbmartinez even though my console logs the users with their data..